/**
 * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved.
 */
import {LoggingLevel, LoggingLevelType} from '../logger/Logger';

declare const __FEATURES__: {
  sendLogs: LoggingLevelType;
  logToConsole: LoggingLevelType;
};

export class BuildFeatures {
  private static _sendLogs: LoggingLevelType;
  private static _logToConsole: LoggingLevelType;

  static get sendLogs(): LoggingLevelType {
    return this._sendLogs;
  }

  static get logToConsole(): LoggingLevelType {
    return this._logToConsole;
  }

  static applyFeatures(): void {
    try {
      const features = __FEATURES__;

      this._sendLogs = 'sendLogs' in features ? features.sendLogs : 'All';
      this._logToConsole = 'logToConsole' in features ? features.logToConsole : 'All';
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
    } catch (e) {
      this._sendLogs = 'All';
      this._logToConsole = 'All';
    }
  }
}

BuildFeatures.applyFeatures();

export default class LoggerDefaults {
  static get defaultLoggingLevel(): LoggingLevel {
    return LoggingLevel[BuildFeatures.sendLogs];
  }

  static get defaultConsoleLoggingLevel(): LoggingLevel {
    return LoggingLevel[BuildFeatures.logToConsole];
  }

  static get defaultTelemetryLoggingLevel(): LoggingLevel {
    return LoggingLevel.Info;
  }
}
