class LogService {
  public debug = (message: string, data?: Record<string, unknown>) => {
    console.debug(message, data);
  };

  public info = (message: string, data?: Record<string, unknown>) => {
    console.info(message, data);
  };

  public warn = (message: string, data?: Record<string, unknown>) => {
    console.warn(message, data);
  };

  public error = (message: string, data?: Record<string, unknown>, root?: unknown) => {
    if (root instanceof AggregateError) {
      for (const error of root.errors) {
        if (error instanceof Error) {
          console.error(error.stack);
        } else {
          console.error(error);
        }
      }
    }
    if (root instanceof Error) {
      console.log(root.stack);
    }
    console.error(message, data);
  };
}

export { LogService };
