/** * Policy-Aware Log Processor * * Wraps a delegate LogRecordProcessor to provide: * 1. Export mode filtering (LOCAL_ONLY, ERRORS_ONLY, INFO_AND_ABOVE) * 2. Severity level filtering * 3. Log body and attribute sanitization * * @see https://github.com/superblocksteam/engineering/blob/main/projects/o11y-refactor/epics/epic-c4-logging-strategy.md */ import type { LogRecordProcessor, ReadableLogRecord } from "@opentelemetry/sdk-logs"; import type { Context } from "@opentelemetry/api"; import { TelemetryPolicy } from "../types/policy.js"; /** * Controls what logs are exported via OTEL. */ export declare enum LogExportMode { /** No log export - local stdout/stderr only */ LOCAL_ONLY = "local_only", /** Export WARN/ERROR/FATAL only (default for cloud-prem) */ ERRORS_ONLY = "errors_only", /** Export INFO and above (not recommended for cloud-prem) */ INFO_AND_ABOVE = "info_and_above" } /** * Logging-specific policy configuration. */ export interface LoggingPolicyConfig { /** What logs to export */ exportMode: LogExportMode; /** Maximum log level for local retention */ localMaxLevel: "trace" | "debug" | "info" | "warn" | "error" | "fatal"; /** Regex patterns to redact from log content */ redactPatterns: RegExp[]; /** Fields to never include in exported logs */ forbiddenFields: Set; } /** * Get logging policy based on telemetry policy. * * @param policy - Telemetry policy * @returns Logging policy configuration */ export declare function getLoggingPolicy(policy: TelemetryPolicy): LoggingPolicyConfig; /** * Log processor that filters and sanitizes logs based on policy. * * This processor: * 1. Blocks all logs if exportMode is LOCAL_ONLY * 2. Filters by severity level based on exportMode * 3. Sanitizes log body and attributes before forwarding */ export declare class PolicyAwareLogProcessor implements LogRecordProcessor { private readonly policy; private readonly delegate; constructor(policy: LoggingPolicyConfig, delegate: LogRecordProcessor); /** * Called when a log record is emitted. */ onEmit(logRecord: ReadableLogRecord, context?: Context): void; /** * Sanitize a log record for export. * Mutates the log record in place to preserve OTEL SDK internal state. */ private sanitizeLogRecord; /** * Check if a string contains a stack trace. */ private containsStackTrace; /** * Sanitize log attributes. */ private sanitizeAttributes; /** * Shutdown the processor. */ shutdown(): Promise; /** * Force flush pending logs. */ forceFlush(): Promise; } //# sourceMappingURL=log-processor.d.ts.map