{"library":"log","title":"Universal Pluggable Logging Utility","description":"The `log` package provides a universal and pluggable logging utility designed for JavaScript applications, currently stable at version 6.3.2. It focuses on being configurable, environment, and presentation agnostic, differentiating itself by not handling output directly but emitting events for external 'writers' (e.g., `log-node` for Node.js environments). Releases are made as needed, with several maintenance and minor feature updates occurring within the last few years. Key features include syslog-compatible log levels (debug, info, notice, warning, error), `debug`-style namespacing for granular control, and support for printf-like message formatting with various placeholders (e.g., `%s`, `%d`, `%j`, `%o`). This design allows developers to write application logs once and integrate different output mechanisms without changing core logging logic. It does not expose `critical`, `alert`, or `emergency` levels, expecting these to be handled as typical exceptions. A crucial differentiator is its modular approach, requiring an explicit 'writer' package to actually emit log messages, making it highly adaptable to various runtime environments and output formats.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install log"],"cli":null},"imports":["import log from 'log';","const namespaceLog = log.get('my-namespace');","import 'log-node';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import log from 'log';\nimport 'log-node'; // Initialize the Node.js writer for log output\n\n// Default logger (writes at 'info' level by default)\nlog.info(\"Application started: %s\", new Date().toISOString());\n\n// Get a namespaced logger (similar to 'debug' library style)\nconst myLibLog = log.get('my-lib');\nmyLibLog.info(\"Initializing 'my-lib' module with config: %j\", { debug: true, port: 3000 });\n\n// Namespaces can be nested\nconst myLibFuncLog = myLibLog.get('func');\nmyLibFuncLog.debug(\"Executing critical function 'processData' for ID: %d\", 12345);\n\n// Log an 'error' level message\nmyLibFuncLog.error(\"Failed to process data due to an unexpected error. Details: %s\", \"Invalid input\");\n\n// Dynamically disable/enable logging for a specific level\nconst { restore } = myLibFuncLog.debug.disable();\nmyLibFuncLog.debug(\"This debug message should not be logged.\");\nrestore(); // Restore previous visibility state\nmyLibFuncLog.debug(\"This debug message should now be logged.\");\n","lang":"javascript","description":"Demonstrates initializing the log system with `log-node`, creating default and namespaced loggers, logging at different levels, and dynamic enabling/disabling of log output.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}