Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
console-log-level
Advanced tools
The console-log-level npm package is a simple logger for Node.js that allows you to log messages at different levels (trace, debug, info, warn, error, fatal). It is lightweight and easy to use, making it suitable for small to medium-sized applications where you need basic logging functionality.
Basic Logging
This feature allows you to log messages at different levels such as info, warn, and error. You can set the logging level when initializing the logger.
const log = require('console-log-level')({ level: 'info' });
log.info('This is an info message');
log.warn('This is a warning message');
log.error('This is an error message');
Custom Logging Levels
This feature allows you to use custom logging levels like debug and trace, providing more granular control over the logging output.
const log = require('console-log-level')({ level: 'debug' });
log.debug('This is a debug message');
log.trace('This is a trace message');
Conditional Logging
This feature allows you to conditionally log messages based on the set logging level. In this example, only messages at the 'warn' level or higher will be logged.
const log = require('console-log-level')({ level: 'warn' });
log.info('This will not be logged');
log.warn('This will be logged');
Winston is a versatile logging library for Node.js with support for multiple transports (e.g., console, file, HTTP). It offers more advanced features compared to console-log-level, such as log formatting, log levels, and custom transports.
Bunyan is a simple and fast JSON logging library for Node.js. It provides a structured logging approach, which is useful for log analysis and monitoring. It also supports log levels and multiple output streams.
Pino is a low-overhead logging library for Node.js that focuses on performance. It provides fast logging with minimal impact on application performance. Pino also supports log levels and JSON output, making it suitable for high-performance applications.
A dead simple logger. Will log to STDOUT or STDERR depending on the
chosen log level. It uses console.info
, console.warn
and
console.error
and hence supports the same API.
Log levels supported: debug, info, warn, error and fatal.
npm install console-log-level
var log = require('console-log-level')({ level: 'info' });
log.debug('a'); // will not do anything
log.info('b'); // will output 'b\n' on STDOUT
log.warn('c'); // will output 'c\n' on STDERR
log.error('d'); // will output 'd\n' on STDERR
log.fatal('e'); // will output 'e\n' on STDERR
Configure the logger by passing an options object:
var log = require('console-log-level')({
prefix: function () { return new Date().toISOString(); },
level: 'info'
});
A string
to specify the log level. Defaults to info
.
Specify this option if you want to set a prefix for all log messages.
This must be a string
or a function
that returns a string.
MIT
FAQs
The most simple logger imaginable
The npm package console-log-level receives a total of 473,352 weekly downloads. As such, console-log-level popularity was classified as popular.
We found that console-log-level demonstrated a not healthy version release cadence and project activity because the last version was released 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.