1.0.5 • Published 3 years ago

@mirasaki/logger v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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:

npm.io

Example error logging

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

Outputs:

npm.io

Functions

  • syslog
  • syserr
  • success
  • info
  • debug
  • database
  • startLog & endLog
  • timestamp: Returns the formatted timestamp for consistency
  • getExecutionTime: Pass process.hrtime() to get precise, formatted timeSince output
  • printErr: print an error object to the console in color
1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago