/**
 * Injectable logging interface and global logger
 */
export interface Logger {
  /** Debug-level messages */
  debug?(...args: unknown[]): void;
  /** Informational messages */
  info(...args: unknown[]): void;
  /** Warning messages */
  warn?(...args: unknown[]): void;
  /** Error messages */
  error(...args: unknown[]): void;
}

let globalLogger: Logger = console;

/**
 * Replace the global logger implementation
 * @param logger Custom logger adhering to Logger interface
 */
export function setLogger(logger: Logger): void {
  globalLogger = logger;
}

/**
 * Retrieve the current global logger
 */
export function getLogger(): Logger {
  return globalLogger;
}
