GithubHelp home page GithubHelp logo

log-msg's Introduction

logMsg

NPM Version NPM Downloads license

Package for Log message util for NodeJS.

Installation

$ npm i log-msg

Usage

const logMsg = require('logMsg');

const logMsgObject = logMsg({
    DEBUG_MODE: true,
    INFO_MODE: true,
    WARN_MODE: true,
    ERROR_MODE: true
})

logMsgObject.log("DEBUG", "test debug message");
logMsgObject.log("INFO", "test info message");
logMsgObject.log("WARN", "test warn message");
logMsgObject.log("ERROR", "test error message");

API Description

logMsg object

Creating logMsg instance with specified configuration

const logMsgObject = logMsg({
    writeLog: false,
    logPath: './log',
    prefixName: 'log_',
    DEBUG_MODE: false,
    INFO_MODE: false,
    WARN_MODE: false,
    ERROR_MODE: false
})

Configuration description

  • writeLog (type: Bool): If set true, create and append log message in log file under logPath, default value is false
  • logPath (type: String): Set the path that the log file storage, default value is './log'
  • prefixName (type: String): Set the prefix name that the log file name, default value is 'log_'
  • DEBUG_MODE (type: Bool): If set true, print the debug msg, default value is false
  • INFO_MODE (type: Bool): If set true, print the info msg, default value is false
  • WARN_MODE (type: Bool): If set true, print the warn msg, default value is false
  • ERROR_MODE (type: Bool): If set true, print the error msg, default value is false

logMsg.log(logType, logMsg)

Print the difference format message by define difference log lavel. The function will check the configuration (include DEBUG_MODE, INFO_MODE, WARN_MODE and ERROR_MODE ) to decide message format.

  • logType (type: String) The log's type: DEBUG, INFO, WARN, ERROR
  • logMsg (type String) The message that you would like to print

logMsg.writeLogFile(msg)

Creating log file and appending text into log file. It will check the configuration writeLog to decide it executeing or not.

  • msg (type: String) The message that you would like to write in log file

Licence

MIT

log-msg's People

Contributors

zhongjunjimmy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.