Skip to content

a debug based logger with preset colors, running on both browsers and Node.

License

Notifications You must be signed in to change notification settings

GloryWong/mini-logger

Repository files navigation

Welcome to mini-logger 👋

Maintenance License: MIT

mini-logger a debug based logger with preset colors, running on both browsers and Node.

Install

npm install @gloxy/mini-logger

or

yarn add @gloxy/mini-logger

or

pnpm add @gloxy/mini-logger

Usage

For all logger methods, the first parameter is a title for it. The second paramter is a formatter, and the rest are any strings one by one for the formatter.

Activate logger

  • Browser: localStorage.debug = 'myapp:*'
  • Node: add the env variable DEBUG = myapp:*

Deactivate by remove them respectively.

// Create the logger instance in the very beginning of your app.
// The namespace is for the logs being distingushiable from other prints, i.e. myapp
const logger = createLogger('myapp');

// Print info
logger('play ball', 'ball player: %s', 'Mary');
logger.info('play ball', 'ball player: %s', 'Mary');

// Print warn
logger.warn('play ball', 'ball player: %s', 'Mary');

// Print success
logger.success('play ball', 'ball player: %s', 'Mary');

// Print error
logger.error('play ball', 'ball player: %s', 'Mary');

// Print debug
logger.debug('play ball', 'ball player: %s', 'Mary');

Author

👤 GloryWong

Show your support

Give a ⭐️ if this project helped you!

About

a debug based logger with preset colors, running on both browsers and Node.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published