@experts_hub/shared
Version:
Shared DTOs, interfaces, and utilities for experts hub applications
41 lines (40 loc) • 1.24 kB
TypeScript
import Transport from 'winston-transport';
import { DiscordAlertService } from './discord-alert.service';
import { AlertSeverity, AlertCategory } from './discord-alert.interface';
export interface DiscordTransportOptions {
level?: string;
webhookUrl: string;
microserviceName: string;
environment: string;
enabled?: boolean;
category?: AlertCategory;
severity?: AlertSeverity;
}
interface WinstonLogInfo {
level: string;
message: string;
timestamp?: string;
stack?: string;
correlationId?: string;
context?: string;
error?: string;
[key: string]: any;
}
export declare class DiscordTransport extends Transport {
private readonly discordService;
private readonly transportOptions;
private logsSent;
constructor(options: DiscordTransportOptions);
log(info: WinstonLogInfo, callback: () => void): void;
private shouldLog;
private sendLogToDiscord;
private mapLogLevelToSeverity;
private buildTitle;
getStats(): {
logsSent: number;
discordStats: ReturnType<DiscordAlertService['getStats']>;
};
close(): void;
}
export declare function createDiscordTransport(options: DiscordTransportOptions): DiscordTransport;
export {};