0.0.7 • Published 3 years ago

@ixigo/martini v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Martini 🍸

Introduction

Martini is a simple to use utility that help you setup logging superfast in your Node server with Zero dependency using nodejs streams. For log rotation you can use external system like logStash.

Installation

You can install Martini using below commands.

npm install --save @ixigo/martini

or

yarn add @ixigo/martini

How to import

If you are using require syntax then you can import using below code.

const { Martini } = require("@ixigo/martini");

If you are using modern import syntax then you can import using below code.

import { Martini } from "@ixigo/martini";

How to use

const path = require("path");
const { Martini } = require("@ixigo/martini");

const logger = new Martini({
  name: "app", // Name of the application (Optional)
  filePath: path.resolve("/var/log/app/", "app.log"), // Log file path (Optional)
});

log file path usually comes from the app config but you can also hardcode if you wanted.

config object is not mandatory and also the fields are also purely optional. So if you don't want to give any config then it uses the default "name" and "filepath".

Default parameter values name - martini filePath - /var/log/martini.log

Methods Available on Martini instance

  • Trace log
    logger.trace({
      data: "trace log",
    });
  • Debug log
    logger.debug({
      data: "debug log",
    });
  • Info log
    logger.info({
      data: "info log",
    });
  • Error log
    logger.error({
      data: "error log",
    });
  • Warn log

    logger.warn({
      data: "warn log",
    });

    Important thing to note - Currently martini only have support for objects to log in all the available logger methods

    There are some extra default information added with logs as per log type are

    1. name - Which is the name of the app given or default if not given
    2. logType which can have below values
    - trace
    - debug
    - info
    - warn
    - error
    1. level which can have below values as per logType
    - 10 (trace)
    - 20 (debug)
    - 30 (info)
    - 40 (warn)
    - 50 (error)
    1. @timestamp which store the log time
0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago