This package has been deprecated

Author message:

Deprecated. Use pub-logger instead.

splogger

1.0.1 • Public • Published

SPLogger

Logger with publish/subscribe mechanism. Writes to file and stdout/stderr

USAGE

const SPLogger = require("splogger");
const logger = SPLogger(); // using default options
 
logger.setOptions({ id: "_log_", stdout: true, path: "./mylogfile" });
 
const subscriber = log => console.log(log);
 
logger.subscribe(subscriber);
logger.log("logging.....!");
// similiar:
logger.error("errors, errors everywhere!");
 
// output: 
// Sat Oct 14 2017 23:04:57 GMT+0100 (BST) :: _log_ :: logging.....!
 
/*
1. stdout is set to true -> you will see an output to stdout (log) or stderr (error),
2. path is set -> file write will be attempted. IO error will go to stderr.
3. all subscribers get notified.
*/
 
const callme = log => console.log(log);
logger.readLogs(callme); // async
// * throws Error if no path provided, IO errors go to stderr
 
// clears log file if path provided
logger.truncate(); // sync

Package Sidebar

Install

npm i splogger

Weekly Downloads

3

Version

1.0.1

License

ISC

Last publish

Collaborators

  • stormcrows