Skip to content

A minimal yet colorful and customizable alternative to javascript's default logger.

License

Notifications You must be signed in to change notification settings

GoodBoyNeon/console-wizard

Repository files navigation


🌈 Console Wizard

🚀 A minimal yet colorful and customizable alternative to javascript's default logger.


Contents


Installation

npm install console-wizard --save
# or
yarn add console-wizard

Usage

import { logger } from 'console-wizard';

logger.error('Invalid syntax for database query!');
logger.info('Environment: Development');
logger.success('All tests passed!');
logger.warn('getDataById() has been depreciated! Use getData instead()');

Output:

image

Tables:

import { logger } from 'console-wizard';

logger.table([
  { name: 'David Lesten', age: 24, occupation: 'Full stack Developer' },
  { name: 'Mark Nimz', age: 32, occupation: 'Backend Developer' },
  { name: 'Lucy Haris', age: 28, occupation: 'Data Scientist' },
  { name: 'Joe Lewis', age: 23, occupation: 'UI/UX Designer' },
  { name: 'Robert Wilson', age: 19, occupation: 'Frontend Developer' },
]);

Output:

tables

Configuration

You can set up the user default configuration by:

import { setWizardConfig } from 'console-wizard';

setWizardConfig({
  /* Weather to include timestamp in the log */
  includeTimestamp: true,

  /* Weather to include status in the log (Ex. "ERROR", "WARN" etc) */
  includeStatus: true,
});

The above configuration would apply for all the loggers in the codebase, except for the ones that have their own configuration (more on that here: #Configuring each log statement)

Note that configuring Console Wizard is completely optional! It ships with the above configuration by default!

Configuring each log statement

Additionally, you can also configure each log statement. For example

import { logger } from 'console-wizard';

logger.info('New GET request on /v1/users', {
  includeTimestamp: false,
});

If both user default configuration (using WizardConfig class) and inline configuration are provided, the configurations are combined with inline one being superior.

Author

License

MIT License

About

A minimal yet colorful and customizable alternative to javascript's default logger.

Resources

License

Stars

Watchers

Forks

Packages

No packages published