/* eslint-disable no-console */

class Logger {
  private readonly caller: string;

  /* Creates a new Logger instance.
   * @param caller - The caller of the logger.
   */
  constructor(caller: string) {
    this.caller = caller;
  }

  static getTimestamp(): string {
    return new Date().toISOString();
  }

  logInfo(message: string, ...args: unknown[]): void {
    console.info(
      `INFO: [envive-ai] ${Logger.getTimestamp()} - ${this.caller} - ${message}`,
      ...args,
    );
  }

  logDebug(message: string, ...args: unknown[]): void {
    console.debug(
      `DEBUG: [envive-ai] ${Logger.getTimestamp()} - ${this.caller} - ${message}`,
      ...args,
    );
  }

  logError(message: string, error: unknown | undefined, ...args: unknown[]): void {
    console.error(
      `ERROR: [envive-ai] ${Logger.getTimestamp()} - ${this.caller} - ${message} error=${error}`,
      args,
    );
  }

  logWarn(message: string, error: unknown | undefined, ...args: unknown[]): void {
    console.warn(
      `WARN: [envive-ai] ${Logger.getTimestamp()} - ${this.caller} - ${message} error=${error}`,
      args,
    );
  }
}

export default Logger;
