@jf/logger

2.0.0 • Public • Published

jfLogger stable

Class for manipulating logs and traces.

Can be used as base class for reporting class or node scripts.

Extend jfObject inheriting all its features and functionalities.

Use jfTranslations so messages can be translated in other languages.

Usage

npm install jfLogger

Example

const jfLogger = require('jf-logger');
jfLogger.translations.addLanguage('en');
// Using new
const logger = new jfLogger();
// As singleton
const logger = jfLogger.i();
logger.log( // 12:34:56 [jfLogger  ] You must set field `name`
    'warn', 
    '', // If empty, class name is used.
    'Debes asignar el campo `%s`',
    'name'
);
logger.log( // 12:34:56 Min length for `Description` is 10 chars.
    'warn', 
    false, // If false, name is hidden.
    'La longitud mínima para `{name}` es {minLength}',
    {
        name      : 'Description',
        minLength : 10
    }
);

Removing/changing colors

If you want differents colors or not colors at all you can overwrite addColorsToLogParams.

If you use an empty function you will remove all colors in parameters.

Package Sidebar

Install

npm i @jf/logger

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

13.8 kB

Total Files

5

Last publish

Collaborators

  • jf