import type { TrySendEvent } from '../api/postEvent';

class Logger {
  private static prefix: string = '[GETID SDK]';

  private constructor() {}

  public static log(message: string): void {
    console.log(`${Logger.prefix} ${JSON.stringify(message)}`);
  }

  public static error(message: string, trySendEvent?: TrySendEvent): void {
    if (trySendEvent) {
      trySendEvent('error', 'started', { message });
      trySendEvent('error', 'completed', { message });
    }
    console.error(`${Logger.prefix} ERROR: ${JSON.stringify(message)}`);
  }

  public static warn(message: string): void {
    console.warn(`${Logger.prefix} ${message}`);
  }
}

export default Logger;
