{"version":3,"file":"node.mjs","names":[],"sources":["../../src/reporters/node.ts"],"sourcesContent":["import type { Reporter } from '../reporter'\nimport { appendFileSync } from 'node:fs'\n\nexport interface FileReporterOptions {\n  /**\n   * Path to the log file.\n   * @default '.diagnostics.log'\n   */\n  logFile?: string\n}\n\n/**\n * Creates a reporter that appends diagnostics as NDJSON to a local file.\n * Each diagnostic is written as a single JSON line.\n *\n * @example\n * ```ts\n * import { createFileReporter } from 'logs-sdk/reporters/node'\n *\n * const log = createLogger({\n *   diagnostics: [diagnostics],\n *   reporters: [consoleReporter, createFileReporter()],\n * })\n * ```\n */\nexport function createFileReporter(options?: FileReporterOptions): Reporter {\n  const logFile = options?.logFile ?? '.diagnostics.log'\n  return (diagnostic, _formatted) => {\n    try {\n      appendFileSync(logFile, `${JSON.stringify(diagnostic)}\\n`)\n    }\n    catch (err: unknown) {\n      console.error(`[logs-sdk]: Failed to write log to \"${logFile}\":`, err)\n    }\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,SAAgB,mBAAmB,SAAyC;CAC1E,MAAM,UAAU,SAAS,WAAW;AACpC,SAAQ,YAAY,eAAe;AACjC,MAAI;AACF,kBAAe,SAAS,GAAG,KAAK,UAAU,WAAW,CAAC,IAAI;WAErD,KAAc;AACnB,WAAQ,MAAM,uCAAuC,QAAQ,KAAK,IAAI"}