Creates a LogSink that forwards every event to the OpenTelemetry Logs API.
Maps each LogEvent to an OTel LogRecord:
LogEvent
LogRecord
timestamp
Date.getTime()
level
severityNumber
severityText
renderedMessage
body
properties
messageTemplate
cleverbrush.message_template
eventId
cleverbrush.event_id
exception.*
Error
Trace correlation (traceId, spanId) is filled in automatically by the OTel SDK from the active context — typically established by tracingMiddleware.
traceId
spanId
tracingMiddleware
The sink itself is per-event; for high-throughput services wrap it with BatchingSink from @cleverbrush/log.
BatchingSink
@cleverbrush/log
Requires that setupOtel({ ... }) has been called so the global LoggerProvider is set; otherwise emissions become no-ops.
setupOtel({ ... })
LoggerProvider
Optional
logger name and attribute sanitization
a LogSink that emits to the OTel Logs pipeline
LogSink
import { createLogger, consoleSink } from '@cleverbrush/log';import { otelLogSink } from '@cleverbrush/otel';const logger = createLogger({ minimumLevel: 'information', sinks: [consoleSink(), otelLogSink()],}); Copy
import { createLogger, consoleSink } from '@cleverbrush/log';import { otelLogSink } from '@cleverbrush/otel';const logger = createLogger({ minimumLevel: 'information', sinks: [consoleSink(), otelLogSink()],});
Creates a LogSink that forwards every event to the OpenTelemetry Logs API.
Maps each
LogEventto an OTelLogRecord:timestamp→ nanoseconds viaDate.getTime()× 1e6level→severityNumberandseverityTextrenderedMessage→bodyproperties→ flat attribute map (functions / symbols dropped, nested objects JSON-stringified)messageTemplate→cleverbrush.message_templateattributeeventId→cleverbrush.event_idattributeexception.*attributes when the event carries anErrorTrace correlation (
traceId,spanId) is filled in automatically by the OTel SDK from the active context — typically established bytracingMiddleware.The sink itself is per-event; for high-throughput services wrap it with
BatchingSinkfrom@cleverbrush/log.Requires that
setupOtel({ ... })has been called so the globalLoggerProvideris set; otherwise emissions become no-ops.