Code Monkey home page Code Monkey logo

wloggertofile's Introduction

module::LoggerToFile status experimental

Class to redirect logging to a file. Logger supports colorful formatting, verbosity control, chaining, combining several loggers/consoles into logging network. Logger provides 10 levels of verbosity [ 0,9 ] any value beyond clamped and multiple approaches to control verbosity. Logger may use console/stream/process/file as input or output. Unlike alternatives, colorful formatting is cross-platform and works similarly in the browser and on the server side. Use the module to make your diagnostic code working on any platform you work with and to been able to redirect your output to/from any destination/source.

The module in JavaScript provides convenient, layered, logging into a file. Logger writes messages( incoming & outgoing ) to file specified by path( outputPath ). Writes each message to the end of a file, creates a new file( outputPath ) if it doesn't exist. Then transfers message to the next output(s) object in the chain if any exists.

Try out from the repository

git clone https://github.com/Wandalen/wLogger
cd wLogger
will .npm.install
node sample/trivial/Sample.s

Make sure you have utility willbe installed. To install willbe: npm i -g willbe@stable. Willbe is required to build of the module.

To add to your project

npm add 'wloggertofile@stable'

Willbe is not required to use the module in your project as submodule.

Usage

Options

  • outputPath { string }[ optional ] - output file path, default dirname/output.log.
  • output { object }[ optional ] - output object for current logger, null by default.

Methods

Output:

  • log
  • error
  • info
  • warn

Chaining:

Other:

  • Check if object exists in logger's inputs list - hasInput
  • Check if object exists in logger's outputs list - hasOutput
Example #1
/* Logging to a file */
var l = new wLoggerToFile();
l.log( 'aa\nbb' );
/* output.log gets
aa
bb
*/
Example #2
/* Add console as output and pass custom output path */
var l = new wLoggerToFile
({
  output : console,
  outputPath : 'out2.txt'
});
l.log( 'aa\nbb' );
/* console and out2.txt get
aa
bb
*/
Example #3
/* Console as input for wLoggerToFile to store console output into file */
var l = new wLoggerToFile();
l.inputFrom( console );
console.log( 'aa\nbb' );
/* save console output into file, message by message */

wloggertofile's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.