1.0.4 • Published 6 years ago
mayo-logs v1.0.4
mayo logs
a very clean and colorful logging method.
installation
npm i mayo-logs
usage
basic structure
const Logger = require('mayo-logs');
const logs = new Logger();
logs.info('info log');
logs.debug('debug log');
logs.warn('warn log');
logs.error('error log');
custom methods
const Logger = require('mayo-logs');
const logs = new Logger();
logs.addMethod({
name: 'verbose', // the name of the logging method, will be assigned to `logs`
color: Logger.Colors.white, // the color of the text that is outputted, `Logger.Colors` is a reference to the chalk module
objectInspectDepth: 3, // how deep nested objects will be logged to
paddLeft: 1, // how many whitespaces are put to the left of the logged text
paddRight: 1, // how many whitespaces are put to the right of the logged text,
levels: [ // contains the "blocks" that are to the left of the logged text
{
color: Logger.Colors.black.bgYellowBright,
text: process.pid,
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgWhite,
text: () => Logger.DateFormat(Date.now(), 'mm/dd/yyyy HH:MM:ss'),
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgMagenta,
text: 'verbose',
paddLeft: 1,
paddRight: 1
}
]
});
logs.verbose('verbose log');
defaults
methods
[
{
name: 'debug',
color: Logger.Colors.reset,
objectInspectDepth: 3,
paddLeft: 1,
paddRight: 1,
levels: [
{
color: Logger.Colors.black.bgYellowBright,
text: process.pid,
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgWhite,
text: () => Logger.DateFormat(Date.now(), 'mm/dd/yyyy HH:MM:ss'),
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgHex('#71bef2'),
text: 'debug',
paddLeft: 1,
paddRight: 1
}
]
},
{
name: 'info',
color: Logger.Colors.reset,
objectInspectDepth: 3,
paddLeft: 1,
paddRight: 1,
levels: [
{
color: Logger.Colors.black.bgYellowBright,
text: process.pid,
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgWhite,
text: () => Logger.DateFormat(Date.now(), 'mm/dd/yyyy HH:MM:ss'),
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgHex('#a8cc8c'),
text: 'info',
paddLeft: 1,
paddRight: 2
}
]
},
{
name: 'warn',
color: Logger.Colors.reset,
objectInspectDepth: 3,
paddLeft: 1,
paddRight: 1,
levels: [
{
color: Logger.Colors.black.bgYellowBright,
text: process.pid,
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgWhite,
text: () => Logger.DateFormat(Date.now(), 'mm/dd/yyyy HH:MM:ss'),
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgHex('#dbab79'),
text: 'warn',
paddLeft: 1,
paddRight: 2
}
]
},
{
name: 'error',
color: Logger.Colors.reset,
objectInspectDepth: 3,
paddLeft: 1,
paddRight: 1,
levels: [
{
color: Logger.Colors.black.bgYellowBright,
text: process.pid,
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgWhite,
text: () => Logger.DateFormat(Date.now(), 'mm/dd/yyyy HH:MM:ss'),
paddLeft: 1,
paddRight: 1
},
{
color: Logger.Colors.black.bgHex('#e88388'),
text: 'error',
paddLeft: 1,
paddRight: 1
}
]
}
]
method structure
{
name: String, // required
color: String, // required
objectInspectDepth: Number, // not required, default to 3
paddLeft: Number, // not required, default to 1
paddRight: Number, // not required, default to 1
levels: [ // required
{
color: String, // required
text: String, // required
paddLeft: Number, // not required, default to 1
paddRight: Number // not required, default to 1
}
]
}
who uses it?
right now, no-one that I know of. if you use my logger in your project, please contact me on discord, using PassTheMayo#1281
.