logtodir

You can easily log to daily created files stored in your chosen directory

Usage no npm install needed!

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

README

Log to files

An easy way to log to a daily created files stored in your chosen directory. If directory does not exist, will be automatically created.

Installation

npm install logtodir

Usage

var Logger = require('logtodir');

// Available filename formats: yyyy-mm-dd, yyyymmdd, dd-mm-yyyy, ddmmyyyy
// Default filename format: yyyy-mm-dd
// Default file extension: txt

// Path to directory / filename format / file extension
var logger = new Logger('path/to/logs', 'yyyymmdd', 'log');

// message
logger.log('My message');
logger.log('This is my another message 2');
logger.log('This is my another message 3');


// OR


var logger = new Logger('path/to/logs');

// message
logger.log('My message');
logger.log('This is my another message 2');
logger.log('This is my another message 3');

Output

1.
/path/to/logs/20160502.log

[2 May 13:36:28]: My message
[2 May 13:36:48]: This is my another message 2
[2 May 13:37:55]: This is my another message 3


2.
/path/to/logs/2016-05-02.txt

[2 May 13:36:28]: My message
[2 May 13:36:48]: This is my another message 2
[2 May 13:37:55]: This is my another message 3