@@ -44,13 +44,13 @@ A logger is identified by a UTI identifier, it defines a threshold level and a d
44
44
45
45
/// The UTI string that identifies the logger. Example : product.module.feature
46
46
public let identifier : String
47
-
47
+
48
48
internal var parent : Logger ?
49
49
50
50
private var thresholdLevelStorage : LogLevel
51
51
private var appendersStorage : [ Appender ]
52
52
private var asynchronousStorage = false
53
- private var timeProviderStorage : ( ( ) -> Date ) ?
53
+ private var timeProviderStorage : ( ) -> Date = Date . init
54
54
55
55
/// If asynchronous is true, only the minimum of work will be done on the main thread, the rest will be deffered to a low priority background thread.
56
56
/// The order of the messages will be preserved in async mode.
@@ -105,7 +105,7 @@ A logger is identified by a UTI identifier, it defines a threshold level and a d
105
105
}
106
106
107
107
/// Gets/sets external time provider for log messages.
108
- /// If `nil` then default behavior `Date()` will be used .
108
+ /// Default behavior is just `Date()`.
109
109
///
110
110
/// Allows to "mock" the time - could be useful in unit tests
111
111
/// which may run on some "virtual" time instead of real one.
@@ -114,7 +114,7 @@ A logger is identified by a UTI identifier, it defines a threshold level and a d
114
114
/// (on the `rootLogger` for example) - entire sub-hierarchy of loggers will have it.
115
115
///
116
116
@objc
117
- public var timeProvider : ( ( ) -> Date ) ? {
117
+ public var timeProvider : ( ) -> Date {
118
118
get {
119
119
if let parent = self . parent {
120
120
return parent. timeProvider
@@ -260,7 +260,7 @@ A logger is identified by a UTI identifier, it defines a threshold level and a d
260
260
var info : LogInfoDictionary = [
261
261
. LoggerName: self . identifier,
262
262
. LogLevel: level,
263
- . Timestamp: ( self . timeProvider ? ( ) ?? Date ( ) ) . timeIntervalSince1970,
263
+ . Timestamp: self . timeProvider ( ) . timeIntervalSince1970,
264
264
. ThreadId: currentThreadId ( ) ,
265
265
. ThreadName: currentThreadName ( )
266
266
]
@@ -289,7 +289,7 @@ A logger is identified by a UTI identifier, it defines a threshold level and a d
289
289
var info : LogInfoDictionary = [
290
290
. LoggerName: self . identifier,
291
291
. LogLevel: level,
292
- . Timestamp: ( self . timeProvider ? ( ) ?? Date ( ) ) . timeIntervalSince1970,
292
+ . Timestamp: self . timeProvider ( ) . timeIntervalSince1970,
293
293
. ThreadId: currentThreadId ( ) ,
294
294
. ThreadName: currentThreadName ( )
295
295
]
0 commit comments