nscl-logwriter
Some logging and date-formatting code I've used multiple places.
Versions
- 1.0.3, 2020-08-17, AMV : First real publish.
Usage
Example:
const log = require('nscl-logwriter')(`/path/to/mylogfile.log`, 'My Log File');
log('Put a message string here.');
log('If you:\n- put multiple lines, then\n- you can put an optional indent level.', 4);
log('Watch this--' + JSON.stringify({a:1,b:2,c:3}, undefined, 2), 12);
const { goodDateAndTime } = require('nscl-logwriter');
log('Formatting a timestamp using goodDateAndTime:');
log(JSON.stringify(goodDateAndTime(1234567891011)));
Which outputs:
My Log File Mon 8-17 6:59pm 1597708760955 | Put a message string here.
My Log File Mon 8-17 6:59pm 1597708760958 | If you:
| - put multiple lines, then
| - you can put an optional indent level.
My Log File Mon 8-17 6:59pm 1597708760959 | Watch this--{
| "a": 1,
| "b": 2,
| "c": 3
| }
My Log File Mon 8-17 6:59pm 1597708760960 | Formatting a timestamp using goodDateAndTime:
My Log File Mon 8-17 6:59pm 1597708760960 | ["Fri 2-13","5:31pm"]