import { LogContext, } from '@rocicorp/logger';
import { otelLogsEnabled } from "../../../otel/src/enabled.js";
import { createLogContext as createLogContextShared, getLogSink, } from "../../../shared/src/logging.js";
import { OtelLogSink } from "./otel-log-sink.js";
export function createLogContext({ log }, context, includeOtel = true) {
    return createLogContextShared({ log }, context, createLogSink(log, includeOtel));
}
function createLogSink(config, includeOtel) {
    const sink = getLogSink(config);
    if (includeOtel && otelLogsEnabled()) {
        const otelSink = new OtelLogSink();
        return new CompositeLogSink([otelSink, sink]);
    }
    return sink;
}
class CompositeLogSink {
    #sinks;
    constructor(sinks) {
        this.#sinks = sinks;
    }
    log(level, context, ...args) {
        for (const sink of this.#sinks) {
            sink.log(level, context, ...args);
        }
    }
}
//# sourceMappingURL=logging.js.map