{"version":3,"file":"logger-DP2BjQ93.mjs","names":[],"sources":["../src/runtime/logger.ts"],"sourcesContent":["/**\n * Structured logging utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.logger` runtime API.\n * At runtime this delegates to `globalThis.tailor.logger`. Use `mockLogger`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n *\n * Unlike `console.*`, each call carries a severity and structured attributes.\n * The message is written to standard output, and the full entry with its\n * attributes is exported over OpenTelemetry, where the attributes are queryable.\n * @example\n * import { logger } from \"@tailor-platform/sdk/runtime\";\n *\n * logger.setAttributes({ requestId: \"r-123\" });\n * logger.info(\"order processed\", { orderId: \"o-1\", total: 99.5 });\n */\n\n/**\n * A single log attribute value. Values outside this union (`null`, nested\n * objects, mixed-type arrays) are silently dropped by the platform.\n */\nexport type LogAttributeValue =\n  | string\n  | number\n  | boolean\n  | readonly string[]\n  | readonly number[]\n  | readonly boolean[];\n\n/**\n * Structured attributes attached to a log entry. The platform keeps at most 32\n * entries, drops any entry whose key exceeds 128 bytes, and truncates string\n * values over 4096 bytes and arrays over 64 elements.\n */\nexport type LogAttributes = Record<string, LogAttributeValue>;\n\n/**\n * Platform API surface for `tailor.logger`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.logger`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as logger from\n * \"@tailor-platform/sdk/runtime/logger\"` or pick individual methods.\n */\nexport interface TailorLoggerAPI {\n  /**\n   * Emits a `debug`-severity log entry.\n   * @param message - The log message\n   * @param attributes - Structured attributes to attach to this entry\n   */\n  debug(message: string, attributes?: LogAttributes): void;\n\n  /**\n   * Emits an `info`-severity log entry.\n   * @param message - The log message\n   * @param attributes - Structured attributes to attach to this entry\n   */\n  info(message: string, attributes?: LogAttributes): void;\n\n  /**\n   * Emits a `warn`-severity log entry.\n   * @param message - The log message\n   * @param attributes - Structured attributes to attach to this entry\n   */\n  warn(message: string, attributes?: LogAttributes): void;\n\n  /**\n   * Emits an `error`-severity log entry.\n   * @param message - The log message\n   * @param attributes - Structured attributes to attach to this entry\n   */\n  error(message: string, attributes?: LogAttributes): void;\n\n  /**\n   * Merges attributes into every subsequent log entry from the current\n   * execution. Later keys overwrite earlier ones; per-call attributes passed to\n   * `debug`/`info`/`warn`/`error` take precedence.\n   * @param attributes - Attributes to attach to subsequent entries\n   */\n  setAttributes(attributes: LogAttributes): void;\n}\n\n// Each wrapper below inlines the `(globalThis as GlobalWithLogger).tailor.logger` cast\n// (rather than sharing a helper) so bundle-log-level.ts's manualPureFunctions\n// can statically match the callee and tree-shake calls below the build's logLevel.\ntype GlobalWithLogger = { tailor: { logger: TailorLoggerAPI } };\n\n/**\n * See {@link TailorLoggerAPI.debug}.\n * @param args - Forwarded to {@link TailorLoggerAPI.debug}\n */\nexport const debug: TailorLoggerAPI[\"debug\"] = (...args) => {\n  (globalThis as GlobalWithLogger).tailor.logger.debug(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.info}.\n * @param args - Forwarded to {@link TailorLoggerAPI.info}\n */\nexport const info: TailorLoggerAPI[\"info\"] = (...args) => {\n  (globalThis as GlobalWithLogger).tailor.logger.info(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.warn}.\n * @param args - Forwarded to {@link TailorLoggerAPI.warn}\n */\nexport const warn: TailorLoggerAPI[\"warn\"] = (...args) => {\n  (globalThis as GlobalWithLogger).tailor.logger.warn(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.error}.\n * @param args - Forwarded to {@link TailorLoggerAPI.error}\n */\nexport const error: TailorLoggerAPI[\"error\"] = (...args) => {\n  (globalThis as GlobalWithLogger).tailor.logger.error(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.setAttributes}.\n * @param args - Forwarded to {@link TailorLoggerAPI.setAttributes}\n */\nexport const setAttributes: TailorLoggerAPI[\"setAttributes\"] = (...args) => {\n  (globalThis as GlobalWithLogger).tailor.logger.setAttributes(...args);\n};\n\n/** `tailor.logger` API object. See {@link TailorLoggerAPI} for method docs. */\nexport const logger: TailorLoggerAPI = {\n  debug,\n  info,\n  warn,\n  error,\n  setAttributes,\n};\n"],"mappings":"AA2FA,MAAa,OAAmC,GAAG,IAAS,CAC1D,WAAiC,OAAO,OAAO,MAAM,GAAG,CAAI,CAC9D,EAMa,MAAiC,GAAG,IAAS,CACxD,WAAiC,OAAO,OAAO,KAAK,GAAG,CAAI,CAC7D,EAMa,MAAiC,GAAG,IAAS,CACxD,WAAiC,OAAO,OAAO,KAAK,GAAG,CAAI,CAC7D,EAMa,OAAmC,GAAG,IAAS,CAC1D,WAAiC,OAAO,OAAO,MAAM,GAAG,CAAI,CAC9D,EAMa,eAAmD,GAAG,IAAS,CAC1E,WAAiC,OAAO,OAAO,cAAc,GAAG,CAAI,CACtE,EAGa,EAA0B,CACrC,MACA,KACA,KACA,MACA,aACF"}