@@ -11,16 +11,13 @@ public final actor LoggerBundler {
11
11
private let buffer : LogBuffer
12
12
private let bufferFlowController : BufferFlowController
13
13
14
- public var configMap : [ LoggerComponentID : Configuration ] = [ : ]
15
14
private( set) var transform : Transform
16
15
17
- private var loggingTask : Task < Void , Never > ?
18
-
19
16
public init (
20
17
components: [ any LoggerComponent ] ,
21
18
buffer: some LogBuffer ,
22
19
bufferFlowController: some BufferFlowController ,
23
- mutations: [ Mutation ] = [ ]
20
+ mutations: [ any Mutation ] = [ ]
24
21
) {
25
22
self . components = components
26
23
self . buffer = buffer
@@ -33,7 +30,9 @@ public final actor LoggerBundler {
33
30
}
34
31
35
32
public func add( mutations: [ Mutation ] ) {
36
- transform = [ transform, mutations. composed ( ) ] . composed ( )
33
+ transform = [
34
+ transform, mutations. composed ( )
35
+ ] . composed ( )
37
36
}
38
37
39
38
/// Sends a Log to the retained LoggerComponents.
@@ -90,6 +89,8 @@ public final actor LoggerBundler {
90
89
}
91
90
}
92
91
92
+ /// Dequeue Log from Buffer and start sending Log to LoggerComponent.
93
+ /// The number and timing of Log dequeues are determined by BufferFlowController.
93
94
@discardableResult
94
95
public func startLogging( ) -> Task < Void , Error > {
95
96
Task {
@@ -115,16 +116,34 @@ public final actor LoggerBundler {
115
116
}
116
117
117
118
public extension LoggerBundler {
119
+ /// Log sending timing
118
120
enum LoggingPolicy : Sendable {
121
+ /// requires the log o be sent to LoggerComponent immediately without storing it in the buffer.
122
+ /// When this is specified, logs can be sent ignoring the waiting order of buffer.
119
123
case immediately
120
124
case bufferingFirst
121
125
}
122
126
127
+ /// Scope of sending logs
128
+ ///
129
+ /// If specified as follows, Logs are sent only to the LoggerComponent
130
+ /// whose LoggerComponentID is defined as myLogger.
131
+ ///
132
+ /// extension LoggerComponentID {
133
+ /// static var myLogger: LoggerComponentID = { .init("myLogger") }
134
+ /// }
135
+ ///
136
+ /// await logger.send(
137
+ /// event,
138
+ /// with: .init(scope: .only(.myLogger))
139
+ /// )
123
140
enum LoggerScope : Sendable {
124
141
case only( [ LoggerComponentID ] )
125
142
case exclude( [ LoggerComponentID ] )
126
143
}
127
144
145
+ /// Settings on how logs are sent
146
+ /// The default settings sends logs to all LoggerComponents after first storing them in a buffer
128
147
struct LoggingOption : Sendable {
129
148
let policy : LoggingPolicy
130
149
let scope : LoggerScope ?
@@ -139,16 +158,6 @@ public extension LoggerBundler {
139
158
}
140
159
}
141
160
142
- public extension LoggerBundler {
143
- struct Configuration {
144
- let allowBuffering : Bool
145
-
146
- public init ( allowBuffering: Bool ) {
147
- self . allowBuffering = allowBuffering
148
- }
149
- }
150
- }
151
-
152
161
public extension LoggerBundler {
153
162
func send( event: TrackingEvent , with option: LoggingOption = . init( ) ) async {
154
163
await send ( event, with: option)
0 commit comments