UNPKG

@storm-stack/log-stream

Version:

A package containing a Storm Stack log adapter to write logs to a stream

29 lines (28 loc) 1.12 kB
import type { LogSink } from "@storm-stack/types/log"; import type { WritableStream } from "node:stream/web"; import type { StreamSinkOptions } from "./types"; /** * A factory that returns a sink that writes to a {@link WritableStream}. * * Note that the `stream` is of Web Streams API, which is different from * Node.js streams. You can convert a Node.js stream to a Web Streams API * stream using [`stream.Writable.toWeb()`] method. * * [`stream.Writable.toWeb()`]: https://nodejs.org/api/stream.html#streamwritabletowebstreamwritable * * @example Sink to the standard error in Deno * ```typescript * const stderrSink = getStreamSink(Deno.stderr.writable); * ``` * * @example Sink to the standard error in Node.js * ```typescript * import stream from "node:stream"; * const stderrSink = getStreamSink(stream.Writable.toWeb(process.stderr)); * ``` * * @param stream - The stream to write to. * @param options - The options for the sink. * @returns A sink that writes to the stream. */ export declare function getSink(stream: WritableStream, options?: StreamSinkOptions): LogSink & AsyncDisposable;