1.0.5 • Published 4 years ago
@mirasaki/logger v1.0.5
logger
Require the package
const logger = require('@mirasaki/logger');Example Usage
logger.syslog('Start initializing...');
logger.syserr('Encountered error while trying to connect to database');
logger.success(`Client initialized after ${logger.getExecutionTime(process.hrtime())}`);
logger.info('Fetching data from API...');
logger.debug(`Execution time: ${logger.getExecutionTime(process.hrtime())}`);
logger.startLog('Application Command Data');
console.table(
[
{
name: 'help',
description: 'Display general information'
},
{
name: 'start',
description: 'Start task'
}
]
);
logger.endLog('Application Command Data');Outputs:

Example error logging
// catch (err) {} or .catch((err) => {})
logger.syserr(`An error has occurred while executing the /zz command`);
logger.printErr(err);Outputs:

Functions
syslogsyserrsuccessinfodebugdatabasestartLog&endLogtimestamp: Returns the formatted timestamp for consistencygetExecutionTime: Passprocess.hrtime()to get precise, formattedtimeSinceoutputprintErr: print an error object to the console in color