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AI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * 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 */\n\nimport {\n  ExportResultCode,\n  ExportResult,\n  hrTimeToMicroseconds,\n} from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This is implementation of {@link LogRecordExporter} that prints LogRecords to the\n * console. This class can be used for diagnostic purposes.\n *\n * NOTE: This {@link LogRecordExporter} is intended for diagnostics use only, output rendered to the console may change at any time.\n */\n\n/* eslint-disable no-console */\nexport class ConsoleLogRecordExporter implements LogRecordExporter {\n  /**\n   * Export logs.\n   * @param logs\n   * @param resultCallback\n   */\n  public export(\n    logs: ReadableLogRecord[],\n    resultCallback: (result: ExportResult) => void\n  ) {\n    this._sendLogRecords(logs, resultCallback);\n  }\n\n  /**\n   * Shutdown the exporter.\n   */\n  public shutdown(): Promise<void> {\n    return Promise.resolve();\n  }\n\n  /**\n   * converts logRecord info into more readable format\n   * @param logRecord\n   */\n  private _exportInfo(logRecord: ReadableLogRecord) {\n    return {\n      resource: {\n        attributes: logRecord.resource.attributes,\n      },\n      instrumentationScope: logRecord.instrumentationScope,\n      timestamp: hrTimeToMicroseconds(logRecord.hrTime),\n      traceId: logRecord.spanContext?.traceId,\n      spanId: logRecord.spanContext?.spanId,\n      traceFlags: logRecord.spanContext?.traceFlags,\n      severityText: logRecord.severityText,\n      severityNumber: logRecord.severityNumber,\n      body: logRecord.body,\n      attributes: logRecord.attributes,\n    };\n  }\n\n  /**\n   * Showing logs  in console\n   * @param logRecords\n   * @param done\n   */\n  private _sendLogRecords(\n    logRecords: ReadableLogRecord[],\n    done?: (result: ExportResult) => void\n  ): void {\n    for (const logRecord of logRecords) {\n      console.dir(this._exportInfo(logRecord), { depth: 3 });\n    }\n    done?.({ code: ExportResultCode.SUCCESS });\n  }\n}\n"]}