Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The glogg npm package is a logging utility designed to enable global logging. It allows developers to create a global logger that can be required and used across different modules in a Node.js application. This makes it easier to manage and configure logging in a centralized manner, especially in large-scale applications where consistent logging practices are crucial.
Creating a global logger
This feature allows you to create a global logger instance that can be used throughout your application. You can name your logger (in this case, 'my-logger') and use various methods such as 'info', 'warn', 'error', etc., to log messages.
const logger = require('glogg')('my-logger');
logger.info('This is an info message');
Listening to log events
This feature enables you to listen to log events. You can attach event listeners to your logger for different log levels (e.g., 'info', 'warn', 'error') and define custom actions, such as logging to a file or sending notifications, when these events occur.
const logger = require('glogg')('my-logger');
logger.on('info', (msg) => {
console.log(`Info: ${msg}`);
});
logger.info('This is an info message');
Winston is a multi-transport async logging library for Node.js. It is similar to glogg in that it provides a powerful and flexible logging mechanism. However, winston offers more customization options, including multiple logging transports (e.g., console, file, HTTP) and custom log levels.
Bunyan is a simple and fast JSON logging library for Node.js services. Like glogg, it supports the concept of a global logger but focuses on JSON for log output, making it more suitable for machine parsing. Bunyan also provides stream-based logging and log rotation capabilities.
Pino is a very low overhead Node.js logger, which is designed for speed and producing logs in a JSON format. It compares to glogg by offering high-performance logging capabilities. Pino also emphasizes child loggers and includes a rich set of tools for processing log files.
Global logging utility.
var getLogger = require('glogg');
var logger = getLogger('my-namespace');
// logs strings
logger.debug('The MOST verbose!');
logger.info('Some important info');
logger.warn('All the warnings to you');
logger.error('OH NO! SOMETHING HAPPENED!');
// supports util.format!
logger.info('%s style!', 'printf');
// log anything
logger.debug({ my: 'obj' });
logger.info([1, 2, 3]);
// somewhere else
logger.on('info', function (msg) {
// do something with msg
});
// must be handled to avoid crashing process
logger.on('error', function (msg) {
// now it won't crash
});
Note: This module makes no assumptions about the log levels and they will always be emitted. If you are looking to filter some out, your listeners will need to have extra logic.
Create a new logger at the given namespace (or the default if no namespace is provided).
Returns an augmented sparkles
EventEmitter object
with 4 methods: debug()
, info()
, warn()
and error()
. When called, these methods emit
an event with the same name. If the first argument is a string, the arguments
are passed through node's util.format()
before being emitted. Other parts
of a node program can get the logger by namespace and listen for the events to
be emitted.
Emits a debug
event with the given msg
.
If the first argument is a string, all arguments are passed to node's
util.format()
before being emitted.
If the first argument is not a string, all arguments will be emitted directly.
Emits a info
event with the given msg
.
If the first argument is a string, all arguments are passed to node's
util.format()
before being emitted.
If the first argument is not a string, all arguments will be emitted directly.
Emits a warn
event with the given msg
.
If the first argument is a string, all arguments are passed to node's
util.format()
before being emitted.
If the first argument is not a string, all arguments will be emitted directly.
Emits a error
event with the given msg
.
If the first argument is a string, all arguments are passed to node's
util.format()
before being emitted.
If the first argument is not a string, all arguments will be emitted directly.
Note: You must handle this event in some way or the node process will crash
when an error
event is emitted.
Standard API from node's EventEmitter
. Use this to listen for events from
the logger methods.
MIT
FAQs
Global logging utility
The npm package glogg receives a total of 1,669,159 weekly downloads. As such, glogg popularity was classified as popular.
We found that glogg demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.