0.5.15 • Published 3 years ago
vv-logger-tiny v0.5.15
Install & Use
npm i vv-logger-tiny
const logger = require('vv-logger-tiny').create(__dirname)
// or
// const logger = require('./index.js').create(__dirname, {level: 'trace', file_name_mask: 'app_${yyyymmdd}.log', days_life: 4, write_to_console: true})
// warning!!! in file_name_mask supported only one date mask - ${yyyymmdd}!!!
logger.trace('hello, trace!')
logger.debug('hello, debug!')
logger.error('hello, error!')
logger.error(new Error('hello, error!'))
logger.debug('user {0} delete document #{1}', {replace: ['Mark', '42']})
logger.error('error when user {0} delete document #{1}', {replace: ['Mark', '42'], traces: new Error('some error')})
Classes
Typedefs
App
Kind: global class
new App(path, options)
Param | Type | Description |
---|---|---|
path | string | where store log files, default = __dirname |
options | constructor_options | additional options |
app._env : _partial.type_env
Kind: instance property of App
app.get_path() ⇒ string
Kind: instance method of App
app.set_option_days_life(days_life)
Kind: instance method of App
Param | Type |
---|---|
days_life | number |
app.set_option_write_to_console(write_to_console)
Kind: instance method of App
Param | Type |
---|---|
write_to_console | boolean |
app.set_option_level(level)
Kind: instance method of App
Param | Type |
---|---|
level | type_log_level |
app.trace(message, options)
Kind: instance method of App
Param | Type |
---|---|
message | string |
options | message_options |
app.debug(message, options)
Kind: instance method of App
Param | Type |
---|---|
message | string |
options | message_options |
app.error(message, options)
Kind: instance method of App
Param | Type |
---|---|
message | string | Error |
options | message_options |
app.save_to_file_force(callback)
Kind: instance method of App
Param | Type |
---|---|
callback | callback_error |
type_log_level : 'trace' | 'debug' | 'error'
logger level, default = 'debug'. if = 'trace', log work with 'trace','debug','error', if = 'debug' - 'debug','error', if 'error' - only 'error'
Kind: global typedef
constructor_options
logger options
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
file_name_mask | string | mask file name for store logger, default = 'app_${yyyymmdd}.log', where '${yyyymmdd}' - date write log. if mask without '${yyyymmdd}', delete old log files not working |
days_life | number | number of days for which log files will be stored, default = 4, only current date = 1, disable delete old log files = 0. you can change it in an already created class in method set_option_days_life |
write_to_console | boolean | write log to file and console (true) or in file only (false), default = true. you can change it in an already created class in method set_option_write_to_console |
level | type_log_level | logger level, default = 'debug'. if = 'trace', log work with 'trace','debug','error', if = 'debug' - 'debug','error', if 'error' - only 'error'. you can change it in an already created class in method set_option_level |
message_options
message options
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
replace | string | Array.<string> | for example: message = 'step #{0} where {1}', replace = 4, 'i create new file', text result = 'step #4 where i create new file' |
traces | string | Error | Array.<string> | Array.<Error> | big attachment to message, for example - error with full stack |
callback_error : function
Kind: global typedef
Param | Type |
---|---|
error | Error |