Logger for JavaScript based on Winston Logger

License: Other

Language: JavaScript


Javascript logging module which writes in the console all warnings and erros

Package Version NodeJS Version

Linux Build Windows Build Test Coverage Downloads Documentation Status

CodeClimate GPA CodeClimate Issues CodeClimate Coverage



npm install --save jsw-logger


Currently, JSW-Logger can be used within a TypeScript based project, as a node dependency or directly in the browser.


First we need to import the dependency:


import { JSWLogger } from "jsw-logger";

Node JS

var JSWLogger = require("jsw-logger").JSWLogger;


<script src="path/to/deps/dist/jsw-logger.min.js"></script>
<!-- This exposes a global "JSWLogger" variable -->


We can instanciate the logger passing a bunch of options:

var Logger = JSWLogger.getInstance({
    level: 2,   // logs "info", "warn" and "error" by default
    hideAllLogs: false, // hides messsages from being logged
    hideLevelLog: false,    // hides the "LOG: " from the begining of the message
    throwError: true   // throw an error when "Logger.throw"

Or we can retrieve the instance with the options by default:

var Logger = JSWLogger.instance;

Also, the options can only by setted when instantiating with the first way. To change them, we should access the options object: Logger.options.throwError = false Or we can drop the instance so we can regenerate it: JSWLogger.__dropInstance()

Note that as this is a singleton (can only be instantiated once), so if you drop the instance, it will be dropped for all


The level logging hierarchy is as follows:

Name Level Method Uses
Silly 6 Logger.silly Some dummy logs, less relevants than a debug
Debug 5 Logger.debug For debugging purposes
Verbose 4 Logger.verbose For extended log messages
Log 3 Logger.log The standar logging
Info 2 Logger.info To show relevant information messages
Logger.inform Works as an alias for "info"
Logger.information Worksas an alias for "info"
Warn 1 Logger.warn To show application warnings
Logger.warning Works as an alias for "warn"
Error 0 Logger.error To output error generated by the application
Logger.throw Same as "error", but throws an Exception is configured to

The lower we set the level whe instanciating, the less methods will output something. Eg.:

Logger.debug("Not shown"); // -> outputs nothing, as the default is log (2)
Logger.info("Some informative message"); // -> INFO: Some informative message
// Can use interpolation
Logger.warn("Be careful %s!", "Ryan"); // -> WARN: Be careful Ryan!
Logger.error("Line %d doesn't compile", 562); // -> ERROR: Line 562 doesn't compile



Project Statistics

Sourcerank 4
Repository Size 1.68 MB
Stars 0
Forks 0
Watchers 1
Open issues 3
Dependencies 33
Contributors 1
Tags 17
Last updated
Last pushed

Top Contributors See all


Packages Referencing this Repo

Javascript logging module that inherits Winston Logger (https://github.com/winstonjs/winston) mod...
Latest release 1.2.6 - Updated
Javascript logging module that inherits Winston Logger (https://github.com/winstonjs/winston) mod...
Latest release 1.2.6 - Published

Recent Tags See all

1.2.6 August 11, 2018
1.2.5 March 17, 2018
1.2.4 May 11, 2017
1.2.3 January 13, 2017
1.2.2 January 12, 2017
1.2.1 January 11, 2017
1.2.0 January 09, 2017
1.1.0 October 23, 2016
v1.0.6 October 18, 2016
1.0.6 October 18, 2016
v1.0.5 October 17, 2016
v1.0.4 August 06, 2016
v1.0.3 August 05, 2016
v1.0.2 August 02, 2016
v1.0.1 June 09, 2016

Something wrong with this page? Make a suggestion

Last synced: 2018-08-11 22:41:16 UTC

Login to resync this repository