{"version":3,"file":"InMemoryLogRecordExporter.js","sourceRoot":"","sources":["../../../src/export/InMemoryLogRecordExporter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,OAAO,yBAAyB;IAC5B,mBAAmB,GAAwB,EAAE,CAAC;IAEtD;;;OAGG;IACO,QAAQ,GAAG,KAAK,CAAC;IAEpB,MAAM,CACX,IAAyB,EACzB,cAA8C;QAE9C,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,cAAc,CAAC;gBACpB,IAAI,EAAE,gBAAgB,CAAC,MAAM;gBAC7B,KAAK,EAAE,IAAI,KAAK,CAAC,2BAA2B,CAAC;aAC9C,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACvC,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,mBAAmB;IACrB,CAAC;IAEM,qBAAqB;QAC1B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;CACF","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"]}