Registry / observability / glogg

glogg

JSON →
library2.2.0jsnpmunverified

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.

observability
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This package is CommonJS-only. Attempting to use ESM `import` will result in a runtime error like 'ERR_REQUIRE_ESM' or 'Cannot use import statement outside a module'.

const getLogger = require('glogg');

Used to subscribe to log events ('debug', 'info', 'warn', 'error'). Attaching a listener to the 'error' event is critical to prevent the Node.js process from crashing on unhandled errors.

logger.on('event', handler);

These methods (e.g., `logger.debug()`, `logger.info()`) are properties of the logger instance returned by `getLogger()`. They cannot be directly imported from the package. Destructuring them from the logger instance has been supported since v1.0.1.

const { info, error } = logger;

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.

const getLogger = require('glogg'); // Create a logger for a specific namespace const mainLogger = getLogger('my-app'); // Create another logger for a different module const dataModuleLogger = getLogger('data-processor'); // Listen for 'info' events from the 'my-app' namespace mainLogger.on('info', (message) => { console.log(`[MainApp Info Listener]: ${message}`); }); // IMPORTANT: You *must* handle 'error' events, or the process will crash. mainLogger.on('error', (errMessage) => { console.error(`[MainApp Error Handler]: CRITICAL! ${errMessage}`); // In a real application, you might exit, log to a different system, etc. }); // Log various types of messages mainLogger.debug('This is a verbose debug message at %s.', new Date().toLocaleTimeString()); mainLogger.info('Application started successfully at %s.', new Date().toISOString()); mainLogger.warn('A configuration setting is missing, falling back to default.'); mainLogger.error('Failed to connect to database: Connection refused!'); // Log without string formatting - all arguments are emitted directly dataModuleLogger.info({ event: 'data_processed', count: 123, status: 'success' }); dataModuleLogger.debug(['debug array', { key: 'value' }]); // Demonstrates a message from a different logger dataModuleLogger.warn('Data processing took longer than expected.'); // Output from a listener that applies custom filtering (conceptual) // For instance, only process warnings from 'data-processor' in a specific way dataModuleLogger.on('warn', (msg) => { if (msg.includes('longer than expected')) { console.log(`[Special Data Warn]: Specific issue noted: ${msg}`); } }); // Simulate another error (this would also crash if not handled by mainLogger's handler) // mainLogger.error('Another critical failure point!');
Debug
Known footguns
breakingThe minimum Node.js version requirement was updated to `>= 10.13.0`.
gotchaThe Node.js process will crash if an `error` event is emitted by a logger and there are no listeners attached to handle it.
gotchaGlogg does not filter log levels internally. All calls to `debug`, `info`, `warn`, and `error` will emit their respective events. Filtering based on desired verbosity or environment must be implemented within your event listeners.
gotchaGlogg is a CommonJS-only package. Attempting to use ESM `import` syntax will lead to runtime errors (`ERR_REQUIRE_ESM` or 'Cannot use import statement outside a module') in environments that don't transpile or handle CJS interoperability.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
4
ahrefsbot
3
script
1
googlebot
1
Resources