Skip to content

Commit

Permalink
make it possible to add logger later
Browse files Browse the repository at this point in the history
  • Loading branch information
k-kohey committed Feb 3, 2022
1 parent 027d576 commit a40d45a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/Parchment/LoggerBundler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct DateProvider {
}

public final class LoggerBundler {
private let components: [LoggerComponent]
private var components: [LoggerComponent]
private let buffer: TrackingEventBufferAdapter
private let flushStrategy: BufferedEventFlushScheduler

Expand All @@ -27,14 +27,17 @@ public final class LoggerBundler {
buffer: TrackingEventBuffer,
loggingStrategy: BufferedEventFlushScheduler
) {
assert(!components.isEmpty, "Should set the any logger with initializer")

self.components = components
self.buffer = .init(buffer)
self.flushStrategy = loggingStrategy
}

public func add(component: LoggerComponent) {
components.append(component)
}

public func send(_ event: Loggable, with option: LoggingOption = .init()) async {
assert(!components.isEmpty, "Should set the any logger")
let loggers: [LoggerComponent] = {
if let scope = option.scope {
return components[scope]
Expand Down

0 comments on commit a40d45a

Please sign in to comment.