0.0.4 ā€¢ Published 6 months ago

@gloxy/mini-logger v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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: * represents all log types(info, success, warn, error, and debug). You can also specify a type.

  • Browser: localStorage.minilogger = 'myapp:*'
  • Node: add the env variable MINILOGGER = myapp:*

Deactivate by remove them respectively.

// Create the logger instance in the very beginning of your app.
// The name is for the logs being distingushiable from other prints, i.e. myapp
const { createLogger } = require('@gloxy/mini-logger');
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');

// Enable or disable logger programmatically
const { enable, disable } = require('@gloxy/mini-logger');
enable('myapp:*');
disable();

Author

šŸ‘¤ GloryWong

Show your support

Give a ā­ļø if this project helped you!

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago