lug-log
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

lug-log

NPM

언어

한국어

Logging library for node.js.

Contribute


issue: Github repository issue tabs

feature: Github repository pull request tabs

Issue and Pull requests are always open.

Quick start


const path = require('path');
const lug = require('lug-log');

const logger = lug.createLogger({
    strategies: [
        new.lug.DailyStrategy({
            level: 'info',
            path: path.join(__dirname, '/log'),
            filename: '%DATE%.log',
        }),
        new.lug.DailyStrategy({
            level: 'error',
            path: path.join(__dirname, '/log/error'),
            filename: '%DATE%.error.log',
        }),
    ],
    formatter: (log) => {
        return `${log.level} - ${log.message}`;
    }
});

logger.info('some log')

LogLevels


debug

info

warn

error

fatal

LogLevels type
export type LogLevels =
  'debug'
  | 'info'
  | 'warn'
  | 'error'
  | 'fatal'

Logging strategy


You can set how to write logs with logging strategy.

1. DailyStrategy

DailyStrategy creates a new log file each day.

Constructor options
option description default required
level Minimum level this strategy will write debug X
path The path that log files will be created (Absolute path) X O
filename File name to save
'%DATE%' must contain. It will replace 'yyyy-MM-dd'
%DATE%.log X
Usages
new.lug.DailyStrategy({
	level: 'info',
  path: path.join(__dirname, '/log'),
  filename: '%DATE%.log',
}),

Format


You can make a form of logs. Set option of function createLogger.

Type
target type
argument Log
return value string
Log interface
attributes type description
level LogLevels Log level
message string Log message
timestamp number Log timestamp
Usages
(log) => {
	return 'format your custom log';
}
Default formatter
[level]	- yyyy-MM-dd HH:mm:ss	message

Readme

Keywords

none

Package Sidebar

Install

npm i lug-log

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

22.3 kB

Total Files

20

Last publish

Collaborators

  • choi-jinwoo