
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@novigi/logger
Advanced tools
Simple and minimalist logger for Node.js applications 🪵
'Hi ${name}!'INFO, WARN, ERROR, DEBUG and TRACEnpm install @novigi/logger
const lib = require('@novigi/logger');
This library contains a collection of standard logging helper methods including logger.info,logger.error etc.
const logger = require('@novigi/logger');
Using to set the loglevel to describe which message level will be logged by the relevant logger to standard output.
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| level | string | required log level TRACE, DEBUG, INFO, WARN, ERROR or SILENT |
Example
logger.setLevel('DEBUG')
Sets a callback function to call for each log line. This can use to redirect log messages to another destination (i.e., to a custom file). Passing a falsy value to the method will reset the callback.
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| cb | function | When a new log line appends callback function will invoke. |
Example
logger.setCallback((line) => { appendToCustomFile(line) }) // appending lines to custom method
logger.setCallback(null) // reset the callback
Sets log color preference to standard output
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| flag | boolean | required log color setting |
Example
logger.setColors(false) // disable printing logs with colors
logger.setColors(true) // enable printing logs with colors
Sets log path to append log lines to a file
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| path | string | required log file path |
Example
logger.setLogPath('path/to/file.log')
logger.setLogPath(null) // Stop printing to a file
Log message at info level
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| [...messages] | string | object | message arguments list accepts any number of log message strings and expects the last argument to be context object. If there are multiple log messages passed as arguments, method joins them with a space. |
| context | object | context variables for the templated messages |
Example
var context = { ans: 'A', name: 'Timmy' }
logger.info('log message') // 2022-10-17 13:19:34.568 - INFO - log message
logger.info('Hi ${name}!', context) // 2022-10-17 13:19:34.568 - INFO - Hi Timmy!
logger.info('Answer: ${ans}.', 'Yes ${ans}!', context) // 2022-10-17 13:19:34.568 - INFO - Correct: A. Yes A!
Log message at error level
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| [...messages] | string | object | message arguments list accepts any number of log message strings and expects the last argument to be context object. If there are multiple log messages passed as arguments, method joins them with a space. |
| context | object | context variables for the templated messages |
Example
var context = { ans: 'A', name: 'Timmy' }
logger.error('log message') // 2022-10-17 13:19:34.568 - ERROR - log message
logger.error('Hi ${name}!', context) // 2022-10-17 13:19:34.568 - ERROR - Hi Timmy!
logger.error('Answer: ${ans}.', 'Yes ${ans}!', context) // 2022-10-17 13:19:34.568 - ERROR - Correct: A. Yes A!
Log message at debug level
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| [...messages] | string | object | message arguments list accepts any number of log message strings and expects the last argument to be context object. If there are multiple log messages passed as arguments, method joins them with a space. |
| context | object | context variables for the templated messages |
Example
var context = { ans: 'A', name: 'Timmy' }
logger.debug('log message') // 2022-10-17 13:19:34.568 - DEBUG - log message
logger.debug('Hi ${name}!', context) // 2022-10-17 13:19:34.568 - DEBUG - Hi Timmy!
logger.debug('Answer: ${ans}.', 'Yes ${ans}!', context) // 2022-10-17 13:19:34.568 - DEBUG - Correct: A. Yes A!
Log message at trace level
Kind: static method of logger
| Param | Type | Description |
|---|---|---|
| [...messages] | string | object | message arguments list accepts any number of log message strings and expects the last argument to be context object. If there are multiple log messages passed as arguments, method joins them with a space. |
| context | object | context variables for the templated messages |
Example
var context = { ans: 'A', name: 'Timmy' }
logger.trace('log message') // 2022-10-17 13:19:34.568 - TRACE - log message
logger.trace('Hi ${name}!', context) // 2022-10-17 13:19:34.568 - TRACE - Hi Timmy!
logger.trace('Answer: ${ans}.', 'Yes ${ans}!', context) // 2022-10-17 13:19:34.568 - TRACE - Correct: A. Yes A!
This is an auto generated file. Please don't make changes manually
FAQs
Simple and minimalist logger for Node.js applications 🪵
We found that @novigi/logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.