1.1.0 • Published 2 years ago
inklinglog v1.1.0
InklingLog
InklingLog is a simple easy to use logger in TypeScript
Installation
To use this module in your project, you need to install it using npm or yarn:
npm install inklinglog
Or
yarn add inklinglog
Usage
import { LogLevel, Color, logger } from 'inklinglog';
// Configure the logging level (DEBUG, INFO, WARN, ERROR). By default it is set to DEBUG
logger.setLogLevel(LogLevel.DEBUG);
// Use the logging methods
logger.debug('This is a debug message.');
logger.info('This is an informational message.');
logger.warn('This is a warning.');
logger.error('This is an error.');
API
Logger
The Logger class is the main class of the module. It contains the following methods:
setLogLevel
Sets the logging level. The logging level determines which messages are logged. The logging level is set to DEBUG by default.
logger.setLogLevel(LogLevel.DEBUG);
getLogLevel
Returns the current logging level.
const logLevel: LogLevel = logger.getLogLevel();
debug
Logs a debug message.
logger.debug('This is a debug message.');
info
Logs an informational message.
logger.info('This is an informational message.');
warn
Logs a warning.
logger.warn('This is a warning.');
error
Logs an error.
logger.error('This is an error.');
LogLevel
The LogLevel enum contains the following values:
- DEBUG
- INFO
- WARN
- ERROR
Color
The Color enum contains the following values:
- RESET
- BLACK
- RED
- GREEN
- YELLOW
- BLUE
- MAGENTA
- CYAN
- WHITE
- GRAY
- LIGHT_RED
- LIGHT_GREEN
- LIGHT_YELLOW
- LIGHT_BLUE
- LIGHT_MAGENTA
- LIGHT_CYAN
- LIGHT_WHITE
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.