0.4.31 • Published 6 years ago

wloggertojstructure v0.4.31

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

wLoggerToJstructure Build Status

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 wLoggerToJstructure

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 wLoggerToJstructure();
/* 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 wLoggerToJstructure();
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 wLoggerToJstructure
({
  output : logger
});
l.log( 'abc' );
/* logger prints
abc
*/
0.4.31

6 years ago

0.4.30

6 years ago

0.4.29

6 years ago

0.4.28

6 years ago

0.4.27

6 years ago

0.4.26

6 years ago

0.4.25

6 years ago

0.4.24

6 years ago

0.4.23

6 years ago

0.4.22

6 years ago

0.4.21

6 years ago

0.4.20

6 years ago

0.4.19

6 years ago

0.4.18

6 years ago

0.4.17

6 years ago

0.4.16

6 years ago

0.4.15

6 years ago

0.4.14

6 years ago

0.4.13

6 years ago

0.4.12

6 years ago

0.4.11

6 years ago

0.4.10

6 years ago

0.4.9

6 years ago

0.4.8

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.2

7 years ago