@funhouse-atelier/logger
v1.0.1
Published
A customized version of the `loglevel` NPM package.
Downloads
2
Readme
@funhouse-atelier/logger
Description
A customized version of the loglevel
NPM package.
Requirements
- Node.js >=16.0.0
Usage
Installing
- Enter the terminal command to install the
logger
package from NPM.
npm i @funhouse-atelier/logger
Instantiating
- Import the
logger
package in a JavaScript file.
import logger from "@funhouse-atelier/logger";
- Instantiate the logger.
const log = logger({ name: "@test.js", level: 0 });
Notes
The options object passed to logger()
is not required, but is included here for demonstration.
The name
option is not required. If name
is included logger()
will return a logger instance with that particular name, and that name will be included in all logs created with that instance. If name
is not included a global logger instance will be returned, and "root" will be used as the name.
The level
option is not required. If level
is included it will set the suppression level of that logger instance, where 0
means "show all log messages" and 5
means "silent". If level
is not included the default level of 3
will be used the first time the logger is instantiated.
Logging to Console
A list of all log output methods available on an instance of logger
, starting with the maximum suppression level for them to be output:
- 0:
log.trace(message)
- 1:
log.debug(message)
- 2:
log.info(message)
- 3:
log.warn(message)
- 4:
log.error(message)