Giter Club home page Giter Club logo

wloggertojs's Introduction

module::LoggerToJs status experimental

Class to redirect logging to JavaScript structure. 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 data structure. Logger writes messages( incoming & outgoing ) to data structure( array of arrays ) specified by( outputData ). Each inner array represent new level of the structure. On write logger puts messages into structure level which is equal to logger level property value. Creates folders if needed level does not exist logger it. Next level is always placed at zero index of previous.Then transfers message to the next output(s) object in the chain if it exists.

Installation

npm install wLoggerToJs

Usage

Options

  • outputData { array }[ optional ] - structure where to write messages, creates own structure by default.
  • output { object }[ optional ] - single output object for current logger, null by default.

Methods

Output:

  • log
  • error
  • info
  • warn

Leveling:

  • Increase current level - up
  • Decrease current level - down

Chaining:

Other:

  • Check if object exists in logger's inputs list - hasInput
  • Check if object exists in logger's outputs list - hasOutput
  • Convert data structure to json string - toJson
Example #1
/* Simple example */
var data = [];
var l = new wLoggerToJs();
/* Increase current level( 0 ) by 2 */
l.log( 'x' );
l.up( 2 );
l.log( 'aa\nbb' );
console.log( l.outputData );
/*
[
  'x',
  [
    [ 'aa\nbb' ]  
  ]
]
*/
Example #2
/* console as input to store it into arrays */
var l = new wLoggerToJs();
l.inputFrom( console );
/* Increase current level by 1 */
l.up( 1 );
console.log( 'aabb' );
console.log( l.toJson() );
/* record console output */
/*
[
  [ 'aabb' ]
]
*/
Example #3
/* another logger as output */
var logger = new wLogger();
var l = new wLoggerToJs
({
  output : logger
});
l.log( 'abc' );
/* logger prints
abc
*/

wloggertojs's People

Contributors

dmvict avatar jackiejoo avatar vmihdal avatar wandalen avatar

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.