1.1.7 • Published 6 years ago

console2file v1.1.7

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Console2File

Node module that allows you to log your console into file (and much more)

GitHub package version bitHound bitHound npm npm license

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 = require('console2file').default;
// or
import c2f from 'console2file';

c2f({
    fileOnly: false,
    labels: true
}); // Overrides default console loggers (and debug)

c2f('rage', {
    labels: true
}); // Creates new function with default options

console.info('Hurray!'); // logs '[INFO] Hurray!' to file ./stdout.log and console

console.rage('quit'); // logs '[RAGE] quit' only to file ./stdout.log

or

var c2f = require('console2file');
// or
import {c2f} from 'console2file';

c2f.config({
    fileOnly: false,
    labels: true
}); // Overrides default console loggers (and debug)

c2f.config('rage', {
    labels: true
}); // Creates new function with default options

console.info('Hurray!'); // logs '[INFO] Hurray!' to file ./stdout.log and console

console.rage('quit'); // logs '[RAGE] quit' only to file ./stdout.log

Parameters

ParameterDefault valueTypeDescription
filePath'./stdout.log'stringFile path to log your console (set empty string or not string to disable)
fileOnlytruebooleanLog only to file or both (file and console)
labelsfalsebooleanDisplay labels (i.e. [LOG], [ERROR], ...)
timestampfalseboolean or stringDisplay timestamp (i.e. [2018-3-16 00:42:29]). Format is from moment.js
interpreterutil.inspectfunctionInterpretation of non string values (allows to log full objects not as [Object object] etc.)

License

MIT