Console2File
Node module that allows you to log your console into file (and much more)
Note
Default console.log
, console.error
, etc. are overridden by this module to stay with familiar functions (only when configuring with default functions names - without params or one as {Options}
)
Table of Contents
Installation
npm install --save console2file
or (preferred)
yarn add console2file
Usage
var c2f = default;// or; ; // Overrides default console loggers (and debug) ; // Creates new function with default options console; // logs '[INFO] Hurray!' to file ./stdout.log and console console; // logs '[RAGE] quit' only to file ./stdout.log
or
var c2f = ;// or; c2f; // Overrides default console loggers (and debug) c2f; // Creates new function with default options console; // logs '[INFO] Hurray!' to file ./stdout.log and console console; // logs '[RAGE] quit' only to file ./stdout.log
Parameters
Parameter | Default value | Type | Description |
---|---|---|---|
filePath | './stdout.log' |
string |
File path to log your console (set empty string or not string to disable) |
fileOnly | true |
boolean |
Log only to file or both (file and console) |
labels | false |
boolean |
Display labels (i.e. [LOG] , [ERROR] , ...) |
timestamp | false |
boolean or string |
Display timestamp (i.e. [2018-3-16 00:42:29] ). Format is from moment.js |
interpreter | util.inspect |
function |
Interpretation of non string values (allows to log full objects not as [Object object] etc.) |
License
MIT