export type LogLevel = 'debug' | 'info' | 'warn' | 'error';

export interface LogContext {
  trace_id?: string;
  request_id?: string;
  user_id?: string;
  component?: string;
  [key: string]: unknown;
}

export interface LogEntry {
  level: LogLevel;
  message: string;
  timestamp: string;
  context: LogContext;
  error?: {
    name: string;
    message: string;
    stack?: string;
  };
}

export interface LoggerConfig {
  /** Minimum log level to emit */
  level: LogLevel;
  /** Service/app name for log context */
  service: string;
  /** Endpoint to send logs to (POST). Omit for console-only. */
  endpoint?: string;
  /** Max entries to buffer before flushing (default: 20) */
  batchSize?: number;
  /** Max ms to wait before flushing (default: 5000) */
  flushInterval?: number;
  /** Install global error/rejection handlers (default: true) */
  captureGlobalErrors?: boolean;
}

export interface LogTransport {
  send(entries: LogEntry[]): void;
}
