{"library":"loglevel","title":"Loglevel: Minimal Logging for JavaScript","description":"loglevel is a minimal, lightweight logging library for JavaScript environments, including browsers and Node.js. Currently at version 1.9.2, it maintains a steady release cadence focusing on stability and reliability. Its core functionality extends standard `console.log` methods to provide level-based logging (trace, debug, info, warn, error) and filtering, while gracefully handling environments where `console` methods might be absent or limited. Key differentiators include its small footprint (1.4 KB minified and gzipped), lack of external dependencies, preservation of original stack trace line numbers (unlike many wrapper-heavy logging frameworks), and seamless integration with various module systems (CommonJS, AMD, global). It ships with built-in TypeScript definitions and ensures consistent logging behavior across diverse JavaScript runtimes, making it a reliable choice for everyday debugging without introducing complex features like appender reconfiguration or advanced filtering rules.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install loglevel"],"cli":null},"imports":["import log from 'loglevel';","const log = require('loglevel');","import log, { LogLevelDesc } from 'loglevel';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import log from 'loglevel';\n\n// Default log level is 'warn'. To see all messages, set the level.\nlog.setLevel('trace');\n\n// Or enable all messages\n// log.enableAll();\n\n// Or programmatically set a specific level\nconst currentEnv = process.env.NODE_ENV || 'development';\nif (currentEnv === 'production') {\n  log.setLevel('error');\n} else {\n  log.setLevel('debug');\n}\n\nlog.trace('This is a trace message');\nlog.debug('This is a debug message');\nlog.info('This is an info message');\nlog.warn('This is a warning message');\nlog.error('This is an error message');\n\n// Example of changing the level dynamically\nsetTimeout(() => {\n  log.setLevel('info');\n  log.info('Log level changed to info after 2 seconds.');\n  log.debug('This debug message will now be hidden.');\n}, 2000);","lang":"typescript","description":"Demonstrates basic usage of loglevel, including setting log levels dynamically and outputting messages at various severities.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}