console2file

1.1.7 • Public • Published

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

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

/console2file/

    Package Sidebar

    Install

    npm i console2file

    Weekly Downloads

    3

    Version

    1.1.7

    License

    MIT

    Unpacked Size

    30.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • rudellandy