ultralog
Simple opinionated logging module for NodeJs.
Overview
Ultralog is opinionated logger framework for any application. This is a wrapper module over the already established libraries to implement logger in simple 3-step code. The idea is to use minimum configuration and achieve a formatted logging output in multi-cloud regions.
Usage
This logger is applied by 3-step process.
- Import the logger class.
- Supply the necessary configuration to logger class
- Use the logger methods available to push the logs to the server
For further configuration, two additional methods are provided:
- mapLogLevels: This method allows you to duplicate the logs over other levels. This is useful in scenario where you may want all info logs or error logs to be printed to trace logs and debug logs.
- setVerbose: This method allows you to print process id, gid, uid, memory usage from process instance
Code Examples
-
Import the Logger class:
// Typescript import { Logger } from "ultralog"; const logger = new Logger("aws");
// JavaScript const { Logger } = require("ultralog"); const consoleLogger = new Logger("console");
-
Supply config (AWS Example):
logger.configure({ accessKeyId: "accessKey", level: "trace", logGroup: "log-group", logStream: "log-stream", region: "aws-region", secretKey: "secret" });
-
Set Verbosity (optional):
logger.setVerbose(true);
-
Map the logging levels (optional):
logger.mapLogLevels({ info: ["info", "debug", "trace"], debug: ["debug"], trace: ["trace"], error: ["error", "debug", "trace"] });
-
Use functions available => info/error/debug/trace
logger.info( "file-name/service/class", "function/method-name", "stringified message" );
The logger method takes first parameter as name of the file and class (if present), second parameter as function name, further parameters as message strings
Contribution and Issues
Visit https://github.com/ashubisht/ultralog for more details
Raise issues at https://github.com/ashubisht/ultralog/issues
Read Contributions (updated soon) for code structure and development