easylogger

Easy winston logger builder by json files

Usage no npm install needed!

<script type="module">
  import easylogger from 'https://cdn.skypack.dev/easylogger';
</script>

README

easyLogger

Easy winston logger builder by json files This project is based in winston logger. More info here: https://github.com/winstonjs/winston

Installation

With npm : npm install easylogger

If you prefer git: git clone https://github.com/GuillermoPena/easyLogger.git

Default Configuration File

{ "enabled": true
, "defaultLanguage": "es"
, "transports": [
    {
      "type":"Console"
    , "enabled": true
    , "colorize": true
    , "level": "debug"
    , "formatter": "consoleFormatter"
    }
  , {
      "type":"File"
    , "enabled": true
    , "filename": "./bot.log"
    , "json": false
    , "formatter": "fileFormatterWithTimestamp"
    , "level": "info"
    }
  , {
      "type":"DailyRotateFile"
    , "enabled": true
    , "filename": "./bot.log"
    , "datePattern": ".yyyyMMdd"
    , "json": false
    , "formatter": "fileFormatterWithTimestamp"
    , "level": "info"
    }
  ]
}

Transport options are winston transport options You can add or remove any winston transport adding field 'enabled' which you can use to (dis)activate logger If you want change any option, you can do it without restart your app. It will be detected it and logger will be rebuilt automatically.

Tests

var EasyLogger = require("easylogger")
var logger = new EasyLogger()
logger.print("Hi!")

logger.setCustomFormatter('File', function(){
  return '[[' + args.message + ']]';
})
logger.print("Bye!")

With default configuration file, this example will log 'Hi' in console, in a file and in a rotate file. Then, it will write 'Bye!' in same transporters but, in file, it will log with a different format (in double brackets)

License

(The MIT License)

Copyright (c) 2015 Guillermo Peña <guillermo.pena.cardano@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.