Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/log_pusher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import debug from './debug.ts'
import { LogBuilder } from './log_builder.ts'
import type { PinoLog, LokiOptions } from './types.ts'
import { Dispatcher, EnvHttpProxyAgent } from "undici";

class RequestError extends Error {
responseBody: string
Expand All @@ -18,9 +19,11 @@ class RequestError extends Error {
export class LogPusher {
#options: LokiOptions
#logBuilder: LogBuilder
#agent: Dispatcher

constructor(options: LokiOptions) {
this.#options = options
this.#agent = new EnvHttpProxyAgent() // for automatic HTTP-proxy support

this.#logBuilder = new LogBuilder({
levelMap: options.levelMap,
Expand Down Expand Up @@ -83,6 +86,7 @@ export class LogPusher {
'Content-Type': 'application/json',
},
body: JSON.stringify({ streams: lokiLogs }),
dispatcher: this.#agent,
},
)

Expand Down