Skip to content

fabioricali/iog-browser

Repository files navigation

iog

Log for browser.

Installation

npm install --save iog-browser

Example

const Iog = require('iog-browser');

const logger = new Iog('my-module-name');

logger.write('my log info');
logger.write({
    also: {
        you: 'want, for example an object'
    }
});

Log format

this produces

logger.write('my log info');

this in your console

[A-CONTEXT][LOG] my log info

API

Iog

Kind: global class

new Iog(contextName, [opts])

Iog instance

ParamTypeDefaultDescription
contextNamestring

es. your-module-name

[opts]object

options

[opts.path=]string

log path

[opts.pretty]booleanfalse

Pretty format

[opts.enableDate]booleanfalse

Enable date

[opts.separator]string"---"

log separator

iog.pause() ⇒ Iog

Pause log writing

Kind: instance method of Iog

iog.resume() ⇒ Iog

Resume log writing

Kind: instance method of Iog

iog.write(msg, [type])

Write log

Kind: instance method of Iog

ParamTypeDefaultDescription
msgstring | object

message log, you can pass also an object with custom params, in this case remember that Error must be get in this way error.message

[type]string"log"

any type that you want like: log, info, error, trace, warn also custom

iog.error(msg)

A wrapper of write that set type to "error"

Kind: instance method of Iog

ParamTypeDescription
msgstring | object

message log, you can pass also an object with custom params, in this case remember that Error must be get in this way error.message

iog.warn(msg)

A wrapper of write that set type to "warn"

Kind: instance method of Iog

ParamTypeDescription
msgstring | object

message log, you can pass also an object with custom params, in this case remember that Error must be get in this way error.message

iog.info(msg)

A wrapper of write that set type to "info"

Kind: instance method of Iog

ParamTypeDescription
msgstring | object

message log, you can pass also an object with custom params, in this case remember that Error must be get in this way error.message

iog.trace(msg)

A wrapper of write that set type to "trace"

Kind: instance method of Iog

ParamTypeDescription
msgstring | object

message log, you can pass also an object with custom params, in this case remember that Error must be get in this way error.message

License

iog-browser is open-sourced software licensed under the MIT license

Author

Fabio Ricali