{"version":3,"file":"InMemoryLogRecordExporter.mjs","names":[],"sources":["../../src/export/InMemoryLogRecordExporter.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\n\nimport type { ReadableLogRecord } from './ReadableLogRecord';\nimport type { LogRecordExporter } from './LogRecordExporter';\n\n/**\n * This class can be used for testing purposes. It stores the exported LogRecords\n * in a list in memory that can be retrieved using the `getFinishedLogRecords()`\n * method.\n */\nexport class InMemoryLogRecordExporter implements LogRecordExporter {\n  private _finishedLogRecords: ReadableLogRecord[] = [];\n\n  /**\n   * Indicates if the exporter has been \"shutdown.\"\n   * When false, exported log records will not be stored in-memory.\n   */\n  protected _stopped = false;\n\n  public export(\n    logs: ReadableLogRecord[],\n    resultCallback: (result: ExportResult) => void\n  ) {\n    if (this._stopped) {\n      return resultCallback({\n        code: ExportResultCode.FAILED,\n        error: new Error('Exporter has been stopped'),\n      });\n    }\n\n    this._finishedLogRecords.push(...logs);\n    resultCallback({ code: ExportResultCode.SUCCESS });\n  }\n\n  public async shutdown(): Promise<void> {\n    this._stopped = true;\n    this.reset();\n  }\n\n  public async forceFlush(): Promise<void> {\n    // nothing to flush\n  }\n\n  public getFinishedLogRecords(): ReadableLogRecord[] {\n    return this._finishedLogRecords;\n  }\n\n  public reset(): void {\n    this._finishedLogRecords = [];\n  }\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,4BAAb,MAAoE;CAClE,sBAAmD,CAAC;;;;;CAMpD,WAAqB;CAErB,OACE,MACA,gBACA;EACA,IAAI,KAAK,UACP,OAAO,eAAe;GACpB,MAAM,iBAAiB;GACvB,uBAAO,IAAI,MAAM,2BAA2B;EAC9C,CAAC;EAGH,KAAK,oBAAoB,KAAK,GAAG,IAAI;EACrC,eAAe,EAAE,MAAM,iBAAiB,QAAQ,CAAC;CACnD;CAEA,MAAa,WAA0B;EACrC,KAAK,WAAW;EAChB,KAAK,MAAM;CACb;CAEA,MAAa,aAA4B,CAEzC;CAEA,wBAAoD;EAClD,OAAO,KAAK;CACd;CAEA,QAAqB;EACnB,KAAK,sBAAsB,CAAC;CAC9B;AACF"}