Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
The fancy-log package is designed for logging messages in Node.js applications with timestamps. It's particularly useful for development environments where tracking the timing of various operations is crucial. The package provides a simple API to prepend a timestamp to your log messages, making it easier to follow the flow of operations and debug issues related to timing.
Basic Logging
This feature allows you to log any message with a timestamp. It's the fundamental functionality of fancy-log, making it straightforward to add time-stamped logging to your application.
const log = require('fancy-log');
log('Hello, world!');
Winston is a multi-transport async logging library for Node.js. Compared to fancy-log, winston offers more flexibility and features such as logging levels (info, warn, error, etc.), multiple storage options (console, file, HTTP, etc.), and custom formatting. It's more suitable for complex applications that require detailed logging configurations.
Morgan is an HTTP request logger middleware for Node.js, designed to log requests in web applications. While fancy-log focuses on general-purpose logging with timestamps, morgan specializes in logging HTTP requests, providing insights into the traffic your web application handles. It's a better choice for web applications that need to monitor HTTP activity.
Debug is a tiny Node.js debugging utility modeled after Node core's debugging technique. It allows you to debug your application in a more granular way by enabling/disabling specific sections of logging output. Unlike fancy-log, which is more about timestamped logging, debug is focused on conditional logging based on the environment, making it ideal for development and debugging purposes.
Log things, prefixed with a timestamp.
var log = require('fancy-log');
log('a message');
// [16:27:02] a message
log.error('oh no!');
// [16:27:02] oh no!
log(msg...)
Logs the message as if you called console.log
but prefixes the output with the
current time in HH:mm:ss format.
log.error(msg...)
Logs the message as if you called console.error
but prefixes the output with the
current time in HH:mm:ss format.
log.warn(msg...)
Logs the message as if you called console.warn
but prefixes the output with the
current time in HH:mm:ss format.
log.info(msg...)
Logs the message as if you called console.info
but prefixes the output with the
current time in HH:mm:ss format.
log.dir(msg...)
Logs the message as if you called console.dir
but prefixes the output with the
current time in HH:mm:ss format.
If the terminal that you are logging to supports colors, the timestamp will be formatted as though it were a Date
being formatted by util.inspect()
. This means that it will be formatted as magenta by default but can be adjusted following node's Customizing util.inspect colors documentation.
For example, this will cause the logged timestamps (and other dates) to display in red:
var util = require('util');
util.inspect.styles.date = 'red';
MIT
2.0.0 (2022-01-07)
FAQs
Log things, prefixed with a timestamp.
The npm package fancy-log receives a total of 988,238 weekly downloads. As such, fancy-log popularity was classified as popular.
We found that fancy-log demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.