application-log-winston-interface
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -5,2 +5,14 @@ # Changelog | ||
### [3.0.1](https://github.com/Anadian/application-log-winston-interface/compare/v3.0.0...v3.0.1) (2022-09-11) | ||
### Bug Fixes | ||
* Transports are now created at init time so options actually take effect. ([d618ea4](https://github.com/Anadian/application-log-winston-interface/commit/d618ea462a124c30f07695a6d1ff04a598fb493f)) | ||
### Refactoring | ||
* Updated .gitignore to ignore test output. ([7cd7c84](https://github.com/Anadian/application-log-winston-interface/commit/7cd7c84dd077efb04c35a6619f7eb8b661d8e66c)) | ||
## [3.0.0](https://github.com/Anadian/application-log-winston-interface/compare/v2.0.6...v3.0.0) (2022-08-30) | ||
@@ -7,0 +19,0 @@ |
{ | ||
"name": "application-log-winston-interface", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A wrapper around initialising Winston with Application-Log Standard levels, colours, and specific formats.", | ||
@@ -5,0 +5,0 @@ "main": "source/main.js", |
@@ -40,3 +40,3 @@ #!/usr/bin/env node | ||
//const FileSystem = require('fs'); | ||
//const Path = require('path'); | ||
//import Path from 'node:path'; | ||
//## External | ||
@@ -100,19 +100,2 @@ import LogForm from 'logform'; | ||
//# Global Variables | ||
var WinstonLogger_Transports = { | ||
file_debug: new Winston.transports.File({ | ||
level: 'debug', | ||
format: WinstonLogFormFormats.file, | ||
eol: '\n', | ||
filename: 'log_debug.log', | ||
maxsize: 1048576, //1 MiB | ||
maxFiles: 4 | ||
}), | ||
console_stderr: new Winston.transports.Console({ | ||
level: 'info', | ||
format: WinstonLogFormFormats.console, | ||
stderrLevels: ['emerg','alert','crit','error','warn','note','info','debug'], | ||
warnLevels: ['warn','note'] | ||
}) | ||
}; | ||
/** | ||
@@ -150,4 +133,22 @@ ## Functions | ||
//Logger.log({process: PROCESS_NAME, module: MODULE_NAME, file: FILENAME, function: FUNCTION_NAME, level: 'debug', message: `received: ${arguments_array}`}); | ||
//console.log( `${FUNCTION_NAME}: ${arguments_array.toString()}` ); | ||
//Variables | ||
var logger = null; | ||
var transports_object = {}; | ||
var transports_options = { | ||
file_debug: { | ||
level: 'debug', | ||
format: WinstonLogFormFormats.file, | ||
eol: '\n', | ||
filename: 'log_debug.log', | ||
maxsize: 1048576, //1 MiB | ||
maxFiles: 4 | ||
}, | ||
console_stderr: { | ||
level: 'info', | ||
format: WinstonLogFormFormats.console, | ||
stderrLevels: ['emerg','alert','crit','error','warn','note','info','debug'], | ||
warnLevels: ['warn','note'] | ||
} | ||
}; | ||
//Parametre checks | ||
@@ -182,4 +183,4 @@ if( typeof(basename) !== 'string' ){ | ||
if( basename != '' && typeof(basename) === 'string' ){ | ||
WinstonLogger_Transports.file_debug.filename = basename; | ||
WinstonLogger_Transports.file_debug._basename = basename; | ||
transports_options.file_debug.filename = basename; | ||
transports_options.file_debug._basename = basename; | ||
} else{ | ||
@@ -191,3 +192,4 @@ return_error = new Error('Param `basename` is an empty string.'); | ||
if( directory != '' && typeof(directory) === 'string' ){ | ||
WinstonLogger_Transports.file_debug.dirname = directory; | ||
transports_options.file_debug.dirname = directory; | ||
//transports_options.file_debug._dest.path = Path.join( directory, basename ); | ||
} else{ | ||
@@ -199,10 +201,12 @@ return_error = new Error('Param `directory` is an empty string.'); | ||
if( console_level != null && typeof(console_level) === 'string' ){ | ||
WinstonLogger_Transports.console_stderr.level = console_level; | ||
transports_options.console_stderr.level = console_level; | ||
} | ||
if( max_size != null && typeof(max_size) === 'number' ){ | ||
WinstonLogger_Transports.file_debug.maxsize = max_size; | ||
transports_options.file_debug.maxsize = max_size; | ||
} | ||
if( max_files != null && typeof(max_files) === 'number' ){ | ||
WinstonLogger_Transports.file_debug.maxFiles = max_files; | ||
transports_options.file_debug.maxFiles = max_files; | ||
} | ||
transports_object.file_debug = new Winston.transports.File( transports_options.file_debug ); | ||
transports_object.console_stderr = new Winston.transports.Console( transports_options.console_stderr ); | ||
logger = Winston.createLogger({ | ||
@@ -212,7 +216,8 @@ level: 'debug', | ||
transports: [ | ||
WinstonLogger_Transports.file_debug, | ||
WinstonLogger_Transports.console_stderr | ||
transports_object.file_debug, | ||
transports_object.console_stderr | ||
] | ||
}); | ||
logger.real_transports = WinstonLogger_Transports; | ||
logger.real_transports = transports_object; | ||
logger.transports_options = transports_options; | ||
logger.setConsoleLogLevel = function( new_level = 'debug' ){ | ||
@@ -232,2 +237,2 @@ var return_error = null; | ||
//# Exports and Execution | ||
export { initWinstonLogger, ApplicationLogStandard as standard, WinstonLogFormFormats as formats, WinstonLogger_Transports as transports }; | ||
export { initWinstonLogger, ApplicationLogStandard as standard, WinstonLogFormFormats as formats }; |
@@ -71,2 +71,3 @@ #!/usr/bin/env node | ||
t.log( t.title ); | ||
var return_error = null; | ||
const expected = { | ||
@@ -94,3 +95,3 @@ instanceOf: TypeError, | ||
var Logger = null; | ||
t.log(`WinstonLogger_Transports: ${ALWI.transports}`); | ||
//t.log(`WinstonLogger_Transports: ${ALWI.transports}`); | ||
try{ | ||
@@ -97,0 +98,0 @@ Logger = ALWI.initWinstonLogger( 'debug.log', './test_log_dir' ); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
163601
574
0