/** * SMTP Logging Utilities * Provides structured logging for SMTP server components */ import * as plugins from '../../../../plugins.js'; import { SecurityLogLevel, SecurityEventType } from '../constants.js'; import type { ISmtpSession } from '../interfaces.js'; /** * SMTP connection metadata to include in logs */ export interface IConnectionMetadata { remoteAddress?: string; remotePort?: number; socketId?: string; secure?: boolean; sessionId?: string; } /** * Log levels for SMTP server */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error'; /** * Options for SMTP log */ export interface ISmtpLogOptions { level?: LogLevel; sessionId?: string; sessionState?: string; remoteAddress?: string; remotePort?: number; command?: string; error?: Error; [key: string]: any; } /** * SMTP logger - provides structured logging for SMTP server */ export declare class SmtpLogger { /** * Log a message with context * @param level - Log level * @param message - Log message * @param options - Additional log options */ static log(level: LogLevel, message: string, options?: ISmtpLogOptions): void; /** * Log debug level message * @param message - Log message * @param options - Additional log options */ static debug(message: string, options?: ISmtpLogOptions): void; /** * Log info level message * @param message - Log message * @param options - Additional log options */ static info(message: string, options?: ISmtpLogOptions): void; /** * Log warning level message * @param message - Log message * @param options - Additional log options */ static warn(message: string, options?: ISmtpLogOptions): void; /** * Log error level message * @param message - Log message * @param options - Additional log options */ static error(message: string, options?: ISmtpLogOptions): void; /** * Log command received from client * @param command - The command string * @param socket - The client socket * @param session - The SMTP session */ static logCommand(command: string, socket: plugins.net.Socket | plugins.tls.TLSSocket, session?: ISmtpSession): void; /** * Log response sent to client * @param response - The response string * @param socket - The client socket */ static logResponse(response: string, socket: plugins.net.Socket | plugins.tls.TLSSocket): void; /** * Log client connection event * @param socket - The client socket * @param eventType - Type of connection event (connect, close, error) * @param session - The SMTP session * @param error - Optional error object for error events */ static logConnection(socket: plugins.net.Socket | plugins.tls.TLSSocket, eventType: 'connect' | 'close' | 'error', session?: ISmtpSession, error?: Error): void; /** * Log security event * @param level - Security log level * @param type - Security event type * @param message - Log message * @param details - Event details * @param ipAddress - Client IP address * @param domain - Optional domain involved * @param success - Whether the security check was successful */ static logSecurityEvent(level: SecurityLogLevel, type: SecurityEventType, message: string, details: Record, ipAddress?: string, domain?: string, success?: boolean): void; } /** * Default instance for backward compatibility */ export declare const smtpLogger: typeof SmtpLogger;