2.0.6 • Published 4 years ago

nestjs-log v2.0.6

Weekly downloads
17
License
MIT
Repository
github
Last release
4 years ago

nestjs-log

Build Status Coverage Status npm

A log can be used as nestjs system logger and application logger. Logs can be rotated based on date('YYYY-MM-DD-HH'), size limit(1G), and old logs will be removed after 14 days. This module wrapps winston.

Usage

npm install nestjs-log

example as application logger

const log = getLog(TAG) // TAG is a label usually as same as the class

log.verbose(`msg`)
log.debug(`msg`)
log.info(`msg`)
log.warn(`msg`)
log.error(`msg`)

// also support splat
log.info('msg', any1, any2, any3)
log.info(obj)

example as nestjs system logger

const app = await NestFactory.create(AppModule, {
    logger: getLog('system').loggerService
  });

environment variables

log level: 
  process.env.LOG_LEVEL ?? 'info'

log dir: 
  process.env.LOG_DIR ?? './log'

log date pattern: 
  process.env.LOG_DATE_PATTERN ?? 'YYYY-MM-DD-HH'

log file name:
  process.env.LOG_FILE_NAME ?? 'app'

log file max size: 
  process.env.LOG_MAX_SIZE ?? '1024m'
  Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number.

log file rotation policy: 
  process.env.LOG_MAX_FILES ?? '14d' 
  Maximum number of logs to keep. This can be a number of files or number of days. If using days, add 'd' as the suffix.

log to console:
  set process.env.NODE_ENV to 'dev'
2.0.6

4 years ago

2.0.3

4 years ago

2.0.5

4 years ago

2.0.2

4 years ago

1.2.0

4 years ago

1.3.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago