Skip to content

Very simple console.log wrapper tailored for tanque's unique job...

License

Notifications You must be signed in to change notification settings

TheShooter89/tq-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@theshooter/tq-logger

npm (scoped) npm bundle size (scoped)

Very simple console.log wrapper tailored for tanque's unique job...

Usage

DISCLAIMER: this package is at ALPHA dev stage. Some legacy console.log features may not be available yet

Installation

npm install @theshooter/tq-logger

Get started

Importing tq-logger returns a function to initialize the logger with your local settings

import logger from '@theshooter/tq-logger'

Just create a wrapper calling tq-logger passing a string argument to set the local module name:

const log = logger('Test Module');

log('Hello tq-logger!');

Output: alt text

Or an optional object to override default settings:

const log = logger('Test Module',{
    styles: {
        heading: {
            INFO: "background-color: blue; color: white;",
        },
        text: {
            INFO: "color: blue;",
        }
    }
});

log('Hello tq-logger!');

Output: alt text


Set SILENT MODE

To disable logging and use SILENT MODE (i.e. in production) set the custom settings object property mode to 'silent':

const log = logger('Test Module',{
    mode: 'silent'
});

log('Hello tq-logger!');

Output: alt text


Set Log Level

To set the log level, append a LEVEL string as second param:

const log = logger('Test Module');

log('Hello tq-logger!', 'warning');

Output: alt text


Set Section

To set a log section, append a SECTION string as second param:

const log = logger('Test Module');

log('Hello tq-logger!', 'ìì++Test Section');

Output: alt text


Set both Level & Section

const log = logger('Test Module');

log('Hello tq-logger!', 'warning', 'ìì++Test Section');

or even:

log('Hello tq-logger!', 'ìì++Test Section', 'warning');

Output: alt text


Defaults

Default options object:

const OPTIONS = {
    mode: "debug",
    styles: {
        heading: {
            ERROR: "background-color: red; color: yellow;",
            WARNING: "background-color: yellow; color: red;",
            INFO: "background-color: green; color: white;",
            DEBUG: "background-color: blue; color: white;"
        },
        section: "font-style: italic",
        text: {
            ERROR: "color: red;",
            WARNING: "color: orange;",
            INFO: "color: green;",
            DEBUG: "color: blue;"
        }
    }
};

Log Levels IDENTIFIERS:

level IDENTIFIER identifier
error 'ERROR' 'error'
warning 'WARNING' 'warning'
info 'INFO' 'info'
debug 'DEBUG' 'debug'
default 'INFO'

About

Very simple console.log wrapper tailored for tanque's unique job...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published