Custom Logger for Apps and API Services
CUstomLoggerService is an utility service that helps you to display debugging, error, informative, log, and warning messages. This tool is made to be used in Node.js, which allows you to easily build efficient, scalable applications. It uses modern JavaScript, is built with TypeScript and bring best JavaScript concepts.
- Compatible with both TypeScript and ES6 (I recommend to use TypeScript)
- NodeJS v8+
- NPM v6+ or yarn v1.17+
- custom-console-colors
You have two options to install this repository.
-
By adding the dependency to your
package.json
file.{ "dependencies": { "custom-logger-service": "^0.2.2" } }
# Install dependencies # NPM npm install # or Yarn yarn
-
By using a package manager
# NPM npm install --save custom-console-color # or Yarn yarn add @ialopezg/core
Default options
const { LoggerService } = require('custom-logger-service')
// With default options
const logger = new Logger();
No options nor styles
const logger = new Logger({
useFormat: false,
});
No options and default format
const config: FormatOptions = {
useFormat: true,
useAppName: false,
usePID: false,
useContext: false,
useEvent: false,
useTimestamp: false,
usePadding: false,
};
const logger = new LoggerService(config);
const message = 'Hello World!';
logger.debug(message);
logger.error(message);
logger.info(message);
logger.log(message);
logger.warn(message);
Event | Color |
---|---|
debug | grey |
error | red |
info | blue |
log | green |
warn | yellow |
Author - Isidro A. Lopez G.
CustomLoggerService is under MIT license.
© Copyright 2019-present - CustomLoggerService by Isidro A. López G.