@invilite/logger
v1.1.1
Published
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9bdbdeea92924bc0b77589082022560c)](https://www.codacy.com/gh/Invilite/logger/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Invilite/logger&utm_campaign=Badge_Grade)
Downloads
12
Readme
@invilite/logger
Simple but powerful logger using RFC-5424, compatible with Syslog.
Highlights
- Focus on high performance
- TypeScript type definitions included
Install
This is a Node.js module available through the npm registry.
Using npm:
$ npm install @invilite/logger
Using bower:
$ bower install @invilite/logger
Using yarn:
$ yarn add @invilite/logger
Usage
import {Logger, LogLevel, LogFormat} from "@invilite/logger";
import {Console} from "@invilite/Transports";
const logger = new Logger();
logger.addTransport(new Console(LogLevel.debug, LogFormat.FORMAT_COLOR));
logger.trace("This is long trace message, used to trace errors", process.argv);
logger.debug("Example debug log, debug is:", false);
logger.info("Example info content.");
Methods
addTransport()
Register new transport.
Syntax
addTransport(transport: AbstractTransport): Logger;
Example
const logger = new Logger();
logger.addTransport(new Console(LogLevel.debug, LogFormat.FORMAT_COLOR));
setTransports()
Replace all transports.
Syntax
setTransports(transports: AbstractTransport[]): Logger;
Example
const logger = new Logger();
logger.setTransports([
new Console(LogLevel.debug, LogFormat.FORMAT_COLOR)
]);
setTimeFormat()
Set time format, in format used by @invilite/date@format().
Syntax
setTimeFormat(format: string): Logger;
getTimeFormat()
Get current time format.
Syntax
getTimeFormat(): string;
License
Library is licensed under a GNU General Public License v3.0