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AE,CAAC,CAAC;KAC5E;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AA/CD,oFA+CC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * # Configuring the internal diag logger level\n *\n * Before OpenTelemetry declarative configuration there was a loosely defined\n * `OTEL_LOG_LEVEL` used by *some* OTel SDK languages, including OTel JS.\n * The supported values were never standardized.\n *\n * With declarative configuration, OpenTelemetry standardized `log_level` to\n * the set of SeverityNumber values defined by the Logs API, but as lowercase\n * string names.\n * https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md#severitynumber\n * https://opentelemetry.io/docs/specs/otel/logs/data-model/#displaying-severity\n *\n * The following is the mapping between log levels:\n *\n * | DiagLogLevel | OTEL_LOG_LEVEL | `log_level` Configuration |\n * | ------------ | -------------- | ------------------------- |\n * | NONE (0)     | \"NONE\"         | use \"fatal\", \"fatal2\", \"fatal3\", or \"fatal4\" |\n * | ERROR (30)   | \"ERROR\"        | error, error2, error3, error4 |\n * | WARN (50)    | \"WARN\"         | warn, warn2, warn3, warn4 |\n * | INFO (60)    | \"INFO\"         | info, info2, info3, info4 |\n * | DEBUG (70)   | \"DEBUG\"        | debug, debug2, debug3, debug4 |\n * | VERBOSE (80) | \"VERBOSE\"      | trace2, trace3, trace4    |\n * | ALL (9999)   | \"ALL\"          | use \"trace\"               |\n *\n * Notable differences between `OTEL_LOG_LEVEL` and `log_level`:\n *\n * - `OTEL_LOG_LEVEL` envvar values are case-insensitive.\n * - `log_level` Declarative Configuration values are case-sensitive.\n * - `log_level` values do not have direct values for \"NONE\" or \"ALL\".\n *   Using \"trace\" for ALL and \"fatal\" for NONE are functionally equivalent.\n * - Declarative Configuration specifies to default to \"info\" level.\n *\n * See https://github.com/open-telemetry/opentelemetry-specification/issues/2039#issuecomment-4306774443\n * for discussion.\n *\n * See also:\n * - `diagLogLevelFromString()` from `@opentelemetry/core`.\n * - `severityNumberConfigFromLogLevelString()` in `@opentelemetry/configuration`.\n */\n\nimport { DiagLogLevel } from '@opentelemetry/api';\nimport type { SeverityNumberConfigModel } from '@opentelemetry/configuration';\n\n/* istanbul ignore next */\n/**\n * @throws Error if `sevNum` is not a known value from the Configuration schema.\n */\nexport function diagLogLevelFromSeverityNumberConfig(\n  sevNum: SeverityNumberConfigModel = 'info'\n): DiagLogLevel {\n  let level: DiagLogLevel;\n  switch (sevNum) {\n    case 'trace':\n      level = DiagLogLevel.ALL;\n      break;\n    case 'trace2':\n    case 'trace3':\n    case 'trace4':\n      level = DiagLogLevel.VERBOSE;\n      break;\n    case 'debug':\n    case 'debug2':\n    case 'debug3':\n    case 'debug4':\n      level = DiagLogLevel.DEBUG;\n      break;\n    case 'info':\n    case 'info2':\n    case 'info3':\n    case 'info4':\n      level = DiagLogLevel.INFO;\n      break;\n    case 'warn':\n    case 'warn2':\n    case 'warn3':\n    case 'warn4':\n      level = DiagLogLevel.WARN;\n      break;\n    case 'error':\n    case 'error2':\n    case 'error3':\n    case 'error4':\n      level = DiagLogLevel.ERROR;\n      break;\n    case 'fatal':\n    case 'fatal2':\n    case 'fatal3':\n    case 'fatal4':\n      level = DiagLogLevel.NONE;\n      break;\n    default:\n      throw new Error(`unexpected SeverityNumberConfigModel value: ${sevNum}`);\n  }\n  return level;\n}\n"]}