2.0.2 • Published 5 years ago

ezlogs v2.0.2

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

EZLogs

EZLogs is an simple and light tool for log

Usage

  1. base
const EZlogs = require('ezlogs')
const logger = EZlogs() // Default option is logging to console
logger.trace('abcd')
logger.debug('log1')
logger.info('log2')
logger.warn('log3')
logger.error('log4')
logger.fatal('log5')
2017-01-23 10:18:18.131 TRACE   ==>  abcd
2017-01-23 10:18:18.131 DEBUG   ==>  log1
2017-01-23 10:18:18.131 INFO    ==>  log2
2017-01-23 10:18:18.131 WARN    ==>  log3
2017-01-23 10:18:18.131 ERROR   ==>  log4
2017-01-23 10:18:18.131 FATAL   ==>  log5
  1. multiple driver
const EZlogs = require('ezlogs')
const logger = EZlogs([{
    type: 'console',
    level: 'trace'
}, {
    type: 'file',
    path: './logs-files',
    filename: 'test_log.log',
    level: 'error'
}]) // All to console, and Only error and fatal to file
logger.trace('abcd')
logger.debug('log1')
logger.info('log2')
logger.warn('log3')
logger.error('log4')
logger.fatal('log5')

Options

nameoptionalwhich driver can useremark
typemustallwhich driver to use.
sepoptionalallbetween time and message, default is #.
leveloptionalalldefault is all to output, e.g. level = 'error',only error and fatal can output.
patternoptionalfile-*default is 'yyyy-MM-dd-HH-mm-ss-SSS'. the pattern in filename
pathmustfile-*full_file_path = path + filename + pattern + '.log'
filenamemustfile-*full_file_path = path + filename + pattern + '.log'
max_backupmustfile-*the max number of logs(file)
expireoptionalfile-dateHow often toggle the log's file, default is 3600 * 24(one day)
max_sizeoptionalfile-numberthe number of per log file, default is 10000
max_sizeoptionalfile-sizethe size of per log file, The unit is kb, default is 1024

Drivers

  1. console

    const EZlogs = require('ezlogs')
    const logger = EZlogs([{
        type: 'console',
        level: 'trace',
    }])
  2. file

    const EZlogs = require('ezlogs')
    const logger = EZlogs([{
        type: 'file',
        path: './logs-files',
        filename: 'test_log.log',
    }])
  3. file-date

    const EZlogs = require('ezlogs')
    const logger = EZlogs([{
        type: 'file-date',
        path: './test/logs',
        filename: 'test',
        expire: 3600 * 24,
        max_backup: 7,
    }])
  4. file-size

    const EZlogs = require('ezlogs')
    const logger = EZlogs([{
        type: 'file-size',
        path: './test/logs',
        filename: 'test',
        max_size: 1024 * 10,
        max_backup: 7
    }])
  5. file-number

    const EZlogs = require('ezlogs')
    const logger = EZlogs([{
        type: 'file-number',
        path: './test/logs',
        filename: 'test',
        max_size: 10 * 10000,
        max_backup: 7
    }])

Contributions

License

Apache2.0

2.0.2

5 years ago

2.0.1

5 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago