Skip to content

dezchai/dezutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dezutil

npm downloads

Logging module.

Usage

Install

NOTE: this package uses Chalk for terminal colors, which means this package will not work in commonjs; Read more here. This script can automate the conversion.

npm install dezutil

Initializing

import Log from 'dezutil'

const logger = new Log()

logger.log('Hello, World!')

The default behaviour is to add a timestamp to each log statement.

[2023-05-05 17:36:52.353] Hello, World!

You can change this by providing a prefix string as the first parameter.

import Log from 'dezutil'

const logger = new Log('API')

logger.log('Hello, World!')
[2023-05-05 17:36:52.353] [API] Hello, World!

You can also destructure the logger into 3 functions, log(), slog(), and elog().

import Log from 'dezutil'

const { log, elog, slog } = Log.create('INFO')

log('Hello, World!')
[2023-05-05 17:36:52.353] [INFO] Hello, World!

Or you can use the default log() from import which has no prefix.

import { log } from 'dezutil'

log('Hello, World!')
[2023-05-05 17:36:52.353] Hello, World!

License

This project is licensed under the MIT License.

About

Custom and colorful logging module for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published