@thesuhu/writelog

1.0.1 • Public • Published

writelog

npm Build Status license

Write logs and rotate every day. This is simple template for loging error or info message to file. Also transport to console when run in development environment.

Install

npm install @thesuhu/writelog --save

Variables

Logs will be split per day and will be stored in a certain size and period. This module will read three environment variables.

  • MAXSIZE: maximum file size, more than it will rotate. the units used are kilobyte, megabyte and gigabyte. Use k, m or g as the suffix. (default: 5m)
  • MAXFILES: maximum period the log file will be kept. This is number of days. Use d as the suffix. (default: 30d)
  • ENV: this is environment development or not. Use dev to add transport to console. Other than dev will not be transported to console. (default: dev)

Usage

below is an example of usage.

const writelog = require('@thesuhu/writelog')

writelog.info('Hello world!')

try {
    // some code
} catch(err) {
    writelog.error(err.message)
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @thesuhu/writelog

Weekly Downloads

7

Version

1.0.1

License

MIT

Unpacked Size

5.48 kB

Total Files

6

Last publish

Collaborators

  • thesuhu