import { z } from 'zod'; /** * OTel severity number mapping (subset): * TRACE=1, DEBUG=5, INFO=9, WARN=13, ERROR=17, FATAL=21 */ export const SEVERITY_TEXT_TO_NUMBER: Record = { trace: 1, debug: 5, info: 9, warn: 13, warning: 13, error: 17, fatal: 21, critical: 21, }; export const zSeverityText = z.enum([ 'trace', 'debug', 'info', 'warn', 'warning', 'error', 'fatal', 'critical', ]); export type ISeverityText = z.infer; export const zLogPayload = z.object({ /** Log message / body */ body: z.string().min(1), /** Severity level as text */ severity: zSeverityText.default('info'), /** Optional override for the numeric OTel severity (1-24) */ severityNumber: z.number().int().min(1).max(24).optional(), /** ISO 8601 timestamp; defaults to server receive time if omitted */ timestamp: z.string().datetime({ offset: true }).optional(), /** Logger name (e.g. "com.example.MyActivity") */ loggerName: z.string().optional(), /** W3C trace context */ traceId: z.string().optional(), spanId: z.string().optional(), traceFlags: z.number().int().min(0).optional(), /** Log-level key-value attributes */ attributes: z.record(z.string(), z.string()).optional(), /** Resource/device attributes (app version, runtime, etc.) */ resource: z.record(z.string(), z.string()).optional(), /** Profile/user ID to associate with this log */ profileId: z.union([z.string().min(1), z.number()]).optional(), }); export type ILogPayload = z.infer; export const zLogBatchPayload = z.object({ logs: z.array(zLogPayload).min(1).max(500), }); export type ILogBatchPayload = z.infer;