项目作者: depascaldc

项目描述 :
A Simple Node-JS logger for colored and beautiful console outputs
高级语言: JavaScript
项目地址: git://github.com/depascaldc/simple-nodejs-logger.git
创建时间: 2020-10-17T10:23:04Z
项目社区:https://github.com/depascaldc/simple-nodejs-logger

开源协议:GNU General Public License v3.0

下载


Simple NodeJS Logger

written by depascaldc


Install

npm install --save logger-nodejs-simple


Example Usage

  1. const { Logger, ConsoleColors } = require('logger-nodejs-simple');
  2. const log = new Logger(Logger.LOG_LEVELS.DEBUG); // LogLevels DEBUG is the highest value and will show you everything
  3. log.log("This is a nice test message for da log XD")
  4. log.info("This is a nice test message for da log XD") // theese two will be shown when loglevel min. MODERATE
  5. log.warn("This is a nice test message for da log XD") // will be shown when loglevel set to ACCURATE
  6. log.debug("This is a nice test message for da log XD") // will only be shown at log level DEBUG
  7. log.out("This is a nice test OUTPUT for da log XD") // will always be shown and not be sent to logger cache ( cannot be uploaded )
  8. var err = new Error("This is a nice test Error for da log XD")
  9. err.code = 'SOME_ERR_CODE'
  10. log.err(err) // will always be hown
  11. log.upload()
  12. .then(url => {
  13. log.out("Uploaded Log: " + ConsoleColors.CYAN_BOLD_BRIGHT + url)
  14. }).catch(err => {
  15. log.out(ConsoleColors.RED_BOLD_BRIGHT + "Coud not upload logs...")
  16. });

Change logLevel

  1. /**
  2. *
  3. * Possible LogLevels are
  4. * NOTHING: -1
  5. * MODERATE: 1
  6. * ACCURATE: 2
  7. * DEBUG: 3
  8. *
  9. */
  10. log.setLogLevel(Logger.LOG_LEVELS.ARGUMENT);

Get current logLevel

  1. let level = log.getLogLevel()