ssh-node-logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

npm version License: MIT Node.js

ssh-node-logger

A zero-dependency npm-package logger utility for Node.js with built-in log rotation, environment-aware output, and optional caching for production use.

Summary

  • The package auto-detects logging mode based on NODE_ENV so you don't need to manually set a flag in each file.
  • Log rotation renames the log file when it exceeds a predefined size (1MB), and caching buffers log messages in production for periodic flushing.
  • Follow the instructions below to test and integrate the package into your project.

Features:

  • Automatic detection of logging mode via NODE_ENV
  • Log rotation when file exceeds 1MB
  • Colorized console output
  • Caching in production for efficient writes
  • Four log levels: LOG, INFO, WARN, ERROR
  • Customizable log path and log level

Install

Install with npm or yarn:

npm install ssh-node-logger

or

yarn add ssh-node-logger

Usage

var logger = require("ssh-node-logger");

// Basic log messages
logger.log("normal log message");
logger.warn("warning message");
logger.error("bad error message");
logger.info("success message");

// Toggle immediate logging or caching.
// When isDebug is true, messages are output immediately.
// When false, messages are cached and flushed at intervals.
logger.isDebug = true;
logger.isDebug = false;

// Set custom log level. Available levels are:
// logger.LOG < logger.INFO < logger.WARN < logger.ERROR
logger.setLevel(logger.INFO);

// Set custom log output path
logger.setPath("path/to/your/logfile.log");

Contributing

Contributions are welcome. Submit issues or pull requests.

License

MIT License

Package Sidebar

Install

npm i ssh-node-logger

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

10.6 kB

Total Files

5

Last publish

Collaborators

  • sshtech