What is @probe.gl/log?
@probe.gl/log is a logging utility designed to provide flexible and powerful logging capabilities for JavaScript applications. It offers features such as log levels, formatting, and conditional logging, making it suitable for both development and production environments.
What are @probe.gl/log's main functionalities?
Basic Logging
This feature allows you to create a basic logger instance and log messages at different levels. The 'log' method is used to log messages with a specified log level.
const {Log} = require('@probe.gl/log');
const log = new Log({id: 'my-app'});
log.log('info', 'This is an info message');
Log Levels
This feature allows you to set different log levels to control the verbosity of the logs. Only messages with a level equal to or higher than the set level will be logged.
const {Log} = require('@probe.gl/log');
const log = new Log({id: 'my-app'});
log.level = 1; // Set log level to 1 (error)
log.log(0, 'This is an error message'); // Will be logged
log.log(1, 'This is a warning message'); // Will not be logged
Conditional Logging
This feature allows you to log messages conditionally. The message will only be logged if the specified condition is true.
const {Log} = require('@probe.gl/log');
const log = new Log({id: 'my-app'});
const condition = true;
log.log({message: 'This is a conditional log', condition});
Custom Formatting
This feature allows you to customize the format of the log messages. You can provide a formatting function that will be applied to each log message.
const {Log} = require('@probe.gl/log');
const log = new Log({id: 'my-app', format: (message) => `[${new Date().toISOString()}] ${message}`});
log.log('info', 'This is a formatted message');
Other packages similar to @probe.gl/log
winston
Winston is a versatile logging library with support for multiple transports, log levels, and formats. It is highly configurable and widely used in Node.js applications. Compared to @probe.gl/log, Winston offers more advanced features such as custom transports and log rotation.
bunyan
Bunyan is a simple and fast JSON logging library for Node.js services. It provides a straightforward API for logging and supports log levels, serializers, and streams. Bunyan is similar to @probe.gl/log in terms of simplicity but focuses on JSON output and structured logging.
pino
Pino is a low-overhead logging library for Node.js that emphasizes performance. It provides a fast and efficient way to log messages with support for log levels and custom serializers. Pino is designed for high-performance applications and offers better performance compared to @probe.gl/log.
@probe.gl/log
Logging and instrumentation tools for JavaScript
probe.gl is a collection of logging, instrumentation, bench-marking and test tools for JavaScript applications.
For documentation please visit the website.