1.3.0 • Published 1 year ago
dezutil v1.3.0
dezutil
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!