2018-01-27 18:16:05 +00:00
|
|
|
import { Transport } from "winston-transport";
|
|
|
|
import {
|
|
|
|
ElasticLog,
|
|
|
|
IElasticLogConstructorOptions
|
|
|
|
} from "./elasticlog.classes.elasticlog";
|
|
|
|
|
|
|
|
export interface IWinstonStandardLogParams {
|
|
|
|
message: string;
|
|
|
|
level: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ElasticWinstonTransport extends Transport {
|
|
|
|
client: ElasticLog<any>;
|
|
|
|
|
|
|
|
constructor(optsArg: IElasticLogConstructorOptions) {
|
|
|
|
super(optsArg);
|
|
|
|
this.client = new ElasticLog(optsArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
log(info, callback) {
|
|
|
|
this.client.log({
|
|
|
|
severity: info.level,
|
2018-01-27 18:46:44 +00:00
|
|
|
message: info.message
|
2018-01-27 18:16:05 +00:00
|
|
|
});
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
}
|