Glogg is a global logging utility designed for Node.js environments, primarily associated with the Gulp.js build system. It offers a straightforward, event-emitter-based interface for namespaced logging. The current stable version is 2.2.0. Releases are infrequent but occur when features or maintenance are required, typically in conjunction with updates within the Gulp ecosystem. A key differentiator is its reliance on `sparkles` (an augmented EventEmitter) to create loggers that emit events for different log levels (debug, info, warn, error). This architecture allows various parts of an application to retrieve a logger by its namespace and subscribe to specific log events, facilitating decoupled log handling. It supports `util.format()` for string interpolation, enabling printf-style logging, and can also log any data type directly. A critical operational aspect is that `error` events *must* be handled by at least one listener to prevent the Node.js process from crashing.
npm install gloggVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create namespaced loggers, subscribe to different log levels (info, error), and emit various types of messages using `util.format()` style string interpolation and direct object logging. It explicitly highlights the critical error handling requirement to prevent process crashes.
Ensure your Node.js environment meets or exceeds version 10.13.0. Users on older Node.js versions must remain on glogg v1.x.
Always attach at least one listener to the `error` event using `logger.on('error', handlerFunction)` to prevent process termination. This is standard Node.js `EventEmitter` behavior for 'error' events.Implement conditional logic within your `logger.on()` handlers to process or discard messages based on their level or other criteria (e.g., `if (level === 'debug' && process.env.NODE_ENV !== 'development') return;`).
Use CommonJS `require()` syntax: `const getLogger = require('glogg');`. If you are in an ESM module context, you may need to use a CJS wrapper or consider alternatives that support ESM directly.Change the import statement to `const getLogger = require('glogg');`. Ensure your project's `package.json` does not have `"type": "module"` if you intend to primarily use CommonJS modules without transpilation.Add an error event listener to your logger instance: `logger.on('error', (msg) => { console.error('Caught glogg error:', msg); /* Handle gracefully */ });`No dependency data recorded yet.