1.1.0 • Published 2 years ago

@crystallizer/logger v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

logger

NPM

This is a simple logger for NodeJS. It is mostly an extension of the basic functionalities of console API. With this, you have 2 levels log with timestamp, catch some Javascript exception and all of that can be logged on screen and in files.

Installation

npm install @crystallizer/logger

Features

  • Logging text in 2 levels (regular log and error log) with timestamp
  • Catching uncaught exception and unhandled promises rejection
  • Write that on screen or in files

Usage

Just log anything like console.log

logger.log("Some text", 123, [11, "22", null, true, { x:123456789 }], { a:123, b:456 })

Log as an error, like console.error

logger.log('Some text', 123, [11, "22", null, true, { x:123456789 }], { a:123, b:456 })

Some simple title screen for you app

logger.title("My App Name", "version number", "test")

Alse can clean screen. Is only for printing in console/screen

logger.clean()

Setup

Decide what you want that lib do for you and in what way. Place this in begining of your app, so logger can work in your way right away.

logger.settings({
  console: true,
  file: {
    log: "./path/to/mylogs",
    error: "./path/to/myErrors"
  },
  tracker: true
})

Setup options

OptionDefaultDescription
consoletrueUsed native console objects for printing on screen.
filefalseEnabled logged in files. Set path to logs folder (as a string) or set paths for individual folders for each log type (as a object).
trackertrueEnabled catching of some Javascript exception.

Author: Vlada Janosevic