ultralog
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

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.

  1. Import the logger class.
  2. Supply the necessary configuration to logger class
  3. Use the logger methods available to push the logs to the server

For further configuration, two additional methods are provided:

  1. 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.
  2. setVerbose: This method allows you to print process id, gid, uid, memory usage from process instance

Code Examples

  1. Import the Logger class:

    // Typescript
    import { Logger } from "ultralog";
    const logger = new Logger("aws");
    // JavaScript
    const { Logger } = require("ultralog");
    const consoleLogger = new Logger("console");
  2. Supply config (AWS Example):

    logger.configure({
     accessKeyId: "accessKey",
     level: "trace",
     logGroup: "log-group",
     logStream: "log-stream",
     region: "aws-region",
     secretKey: "secret"
    });
  3. Set Verbosity (optional):

    logger.setVerbose(true);
  4. Map the logging levels (optional):

    logger.mapLogLevels({
       info: ["info", "debug", "trace"],
       debug: ["debug"],
       trace: ["trace"],
       error: ["error", "debug", "trace"]
    });
  5. 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

Readme

Keywords

Package Sidebar

Install

npm i ultralog

Weekly Downloads

2

Version

0.1.9

License

ISC

Unpacked Size

54.8 kB

Total Files

17

Last publish

Collaborators

  • ashubisht