@salesduck/logger
v4.1.0
Published
Allows you to record and transmit messages to the consumer
Downloads
77
Readme
Logger
Implements a logger that allows you to record messages at various levels
Setup
Install package
yarn add @salesduck/logger
Usage
You can develop new logger with custom levels
import { Logger } from '@salesduck/logger';
enum MyLevels = {
CRITICAL,
FATAL
};
class MyLogger extends Logger {
critical(log: Log): void {
return this.log({ name: 'critical', priority: MyLevels.CRITICAL }, log);
}
fatal(log: Log): void {
return this.log({ name: 'fatal', priority: MyLevels.FATAL }, log);
}
}
Or extends existing
import { DefaultLogger } from '@salesduck/logger';
class MyLogger extends DefaultLogger {
warning(log: Log): void {
return this.log({ name: 'fatal', priority: 1 }, log);
}
}
You can specify log type
type MyLog = {
orderId?: string;
userId?: number;
}
const logger = new DefaultLogger<MyLog>;