{"id":14689,"library":"log-driver","title":"Log Driver","description":"Log Driver is a minimalistic Node.js logging framework, currently at version 1.2.7. It is designed exclusively to output all logs to standard output (stdout), following a Unix-like philosophy. Its core differentiator is the complete decoupling of log processing from the application itself, advocating for external tools and operating system pipes (e.g., `2>&1 | logger` or `>> somefile.log`) to handle persistence, routing, and filtering of logs. The package provides configurable log levels (e.g., error, warn, info, debug, trace) and allows for custom formatting functions, including JSON output. Unlike many contemporary logging libraries, Log Driver does not include built-in transports for files, network, or databases. The project appears to be abandoned, with its last publish occurring 8 years ago as of February 2018, implying no active release cadence or maintenance.","status":"abandoned","version":"1.2.7","language":"javascript","source_language":"en","source_url":"git://github.com/cainus/logdriver","tags":["javascript","logging","logger","log"],"install":[{"cmd":"npm install log-driver","lang":"bash","label":"npm"},{"cmd":"yarn add log-driver","lang":"bash","label":"yarn"},{"cmd":"pnpm add log-driver","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and primarily used via direct property access on the module export. Attempting to use `import` syntax will result in errors in an ESM context.","wrong":"import { logger } from 'log-driver';","symbol":"logger","correct":"const logger = require('log-driver').logger;"},{"note":"The default export is a factory function for creating new logger instances with custom configurations. It is CommonJS-only; direct ESM default imports are not supported.","wrong":"import customLogger from 'log-driver';","symbol":"default export (factory)","correct":"const customLogger = require('log-driver')({ level: 'info' });"},{"note":"Logger instances expose level-specific methods (e.g., `.info()`, `.warn()`, `.error()`) rather than a generic `.log()` with a level argument.","wrong":"logger.log('info', 'message');","symbol":"Logger instances","correct":"logger.info('message');"}],"quickstart":{"code":"const logDriver = require('log-driver');\n\n// Get the default logger instance\nconst defaultLogger = logDriver.logger;\n\ndefaultLogger.info('Application started at %s', new Date().toISOString());\ndefaultLogger.warn('Potential issue: %j', {\n  severity: 'medium',\n  reason: 'Resource nearing limit'\n});\ndefaultLogger.error(new Error('Something critical happened!'), 'An unexpected error occurred.');\n\n// Configure a custom logger with specific levels and a lower threshold\nconst customLevelsLogger = logDriver({\n  levels: ['audit', 'critical', 'notify'],\n  level: 'critical' // Only log 'critical' and 'audit'\n});\n\ncustomLevelsLogger.audit('User %s performed action %s', 'admin', 'login');\ncustomLevelsLogger.critical('Database connection lost!');\ncustomLevelsLogger.notify('New update available (this will not show)'); // Below 'critical' level\n\n// Demonstrate a custom formatter for JSON output\nconst jsonLogger = logDriver({\n  format: function() {\n    const args = Array.from(arguments);\n    const level = args.shift(); // First arg is the log level implicitly passed by the method\n    const timestamp = new Date().toISOString();\n    return JSON.stringify({\n      timestamp,\n      level,\n      message: args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ')\n    });\n  }\n});\n\njsonLogger.info('This is a JSON log message', { data: 'example', id: 123 });\n\n// To experience log-driver's full effect, run this script and pipe its output:\n// node your-app.js 2>&1 | tee app.log | some-log-processor.js\n","lang":"javascript","description":"Demonstrates how to get the default logger, configure a logger with custom levels and thresholds, and apply a custom JSON formatting function, highlighting its stdout-centric design."},"warnings":[{"fix":"Migrate to a actively maintained logging solution such as Winston, Pino, or pino-pretty, which offer robust features, performance, and ongoing support.","message":"The `log-driver` package is abandoned and has not received updates since February 2018. This implies a lack of security patches, bug fixes, and compatibility updates for newer Node.js versions or evolving ecosystem standards. Continued use in production environments is highly risky.","severity":"breaking","affected_versions":">=1.x.x"},{"fix":"Ensure `log-driver` is used only in CommonJS modules with `require()`. For projects using ES Modules, consider migrating to an ESM-compatible logging library or using a CommonJS wrapper.","message":"This package is CommonJS-only and does not support ES Modules (`import`/`export`). Attempting to use `log-driver` in an ESM context will lead to runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Users must implement external piping mechanisms (e.g., shell redirection `>>`, or piping to tools like `logger` or custom scripts) to achieve log storage or forwarding beyond `stdout`/`stderr`.","message":"Log Driver's design relies heavily on operating system-level piping for log persistence and transport (e.g., sending to files, syslog, or external services). It does not provide built-in transports like modern logging libraries.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly test `log-driver` on your target Node.js version. For production, prioritize migration to a actively maintained logger that explicitly supports modern Node.js versions.","message":"The package's `engines` field specifies Node.js `>=0.8.6`, which is an extremely old and unsupported version of Node.js. While it might still function on newer Node.js runtimes, unexpected behavior, deprecation warnings, or outright compatibility issues are highly probable due to unmaintained dependencies or breaking changes in Node.js itself.","severity":"gotcha","affected_versions":"All versions on modern Node.js (>v8)"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use `const logDriver = require('log-driver');` instead of `import` statements. If your project is pure ESM, consider migrating to an ESM-compatible logging library.","cause":"Attempting to `import` the CommonJS-only `log-driver` package in an ES Module context (e.g., a `.mjs` file or a project with `\"type\": \"module\"` in `package.json`).","error":"TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension in <module path> for <log-driver module path>"},{"fix":"Ensure the logger is configured with a sufficiently low `level` to enable the desired methods. For 'trace' output, initialize with `require('log-driver')({ level: 'trace' })` or lower.","cause":"The logger instance was initialized with a `level` option that is higher (less verbose) than 'trace', effectively disabling the `trace` method. For example, setting `level: 'info'` will disable `debug` and `trace` methods.","error":"TypeError: logger.trace is not a function"},{"fix":"This package is not designed for browser use. For client-side logging, use browser-native `console` methods or a browser-compatible logging library (e.g., `loglevel`).","cause":"`log-driver` is a Node.js-specific package that uses Node.js's `require` function, which is not available in client-side browser environments.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}