
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@node-cli/logger
Advanced tools
Logger is a dead-simple console logger for nodejs command-line applications.
> cd your-project
> npm install --save-dev @node-cli/logger
import { Logger } from "@node-cli/logger";
const log = new Logger();
log.info("this is an informational log");
log.warn("this is a warning log");
log.error("this is an error log");
Logger relies on console behind the scenes, and therefore supports the same string substitution capabilities and uses the following methods:
| Method | Description | Output color |
|---|---|---|
| debug | Outputs a message to the console with the log level debug | grey |
| log | For general output of logging information. | white |
| info | Informative logging of information. | blue |
| warn | Outputs a message to the console with the log level debug | yellow |
| error | Outputs an error message. | red |
You can disable logging with silent:
import { Logger } from "@node-cli/logger";
const log = new Logger();
log.info("this will be logged");
// disabling logs in production for example
log.silent = process.env.NODE_ENV === "production";
log.info("but this will not");
log.silent = false;
log.info("this will be logged again!");
This option can also be passed to the constructor:
import { Logger } from "@node-cli/logger";
const log = new Logger({ silent: true });
log.info("this will not be logged");
log.silent = false;
log.info("this will be logged again!");
You can disable colors with boring:
import { Logger } from "@node-cli/logger";
const log = new Logger();
log.info("this will be logged in the default [info] color");
// disabling colors in test mode for example
log.boring = process.env.NODE_ENV === "test";
log.info("but this will not have any colors :/");
log.boring = false;
log.info("colors are back!");
This option can also be passed to the constructor:
import { Logger } from "@node-cli/logger";
const log = new Logger({ boring: true });
log.info("this will not be logged in color");
log.boring = false;
log.info("this will be logged again!");
You can add a prefix to the logs with prefix:
import { Logger } from "@node-cli/logger";
const log = new Logger();
log.info("this will be logged with no prefix");
log.prefix = "[INFO]";
log.info("this will have a prefix!");
The output of that last line would be:
> [INFO] this will have a prefix!
This option can also be passed to the constructor:
import { Logger } from "@node-cli/logger";
const log = new Logger({ prefix: "Log:" });
log.info("this will be logged with a prefix");
log.prefix = false;
log.info("this will be NOT be logged with a prefix");
You can add a timestamp to the logs with timestamp:
import { Logger } from "@node-cli/logger";
const log = new Logger();
log.info("this will be logged with no timestamp");
log.timestamp = true;
log.info("this will have a timestamp!");
The output of that last line would look like:
> [ Tue Feb 02 2021 8:32:58 PM ] this will have a timestamp!
This option can also be passed to the constructor:
import { Logger } from "@node-cli/logger";
const log = new Logger({ timestamp: true });
log.info("this will be logged with a timestamp");
log.timestamp = false;
log.info("this will be NOT be logged with a timestamp");
MIT © Arno Versini
FAQs
A tiny console logger for nodejs CLI apps
The npm package @node-cli/logger receives a total of 205 weekly downloads. As such, @node-cli/logger popularity was classified as not popular.
We found that @node-cli/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.