Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transport(level: string, indexPrefix: string): winstonElasticsearch {
return new winstonElasticsearch({
indexPrefix,
level,
client: this.elasticsearchClient,
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
transformer:(log: any): any => {
const transformed: {[x: string]: {}} = {};
transformed['@timestamp'] =
log.timestamp ? log.timestamp : new Date().toISOString();
transformed.message = log.message;
transformed.severity = log.level;
// Log error Code
if (log.meta.errorCode) {
transformed.errorCode = log.meta.errorCode;
delete log.meta.errorCode;
}
// Log unique ID