File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
Formatters/OSLogFormatter Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // Glider
3+ // Fast, Lightweight yet powerful logging system for Swift.
4+ //
5+ // Created & Maintained by Mobile Platforms Team @ ImmobiliareLabs.it
6+ // Email: mobile@immobiliare.it
7+ // Web: http://labs.immobiliare.it
8+ //
9+ // Authors:
10+ // - Daniele Margutti <hello@danielemargutti.com>
11+ //
12+ // Copyright ©2022 Immobiliare.it SpA.
13+ // Licensed under MIT License.
14+ //
15+
16+ import Foundation
17+
18+ /// The`OSLogFormatter` is used to print messages directly on XCode debug console with OSLog.
19+ open class OSLogFormatter : FieldsFormatter {
20+
21+ // MARK: - Initialization
22+
23+ public init ( ) {
24+ super. init ( fields: Self . defaultFields ( ) )
25+ }
26+
27+ /// Return the default fields of the default `TerminalFormatter` configuration.
28+ ///
29+ /// - Parameters:
30+ /// - colorize: colorize mode.
31+ /// - colorizeFields: colorized fields.
32+ /// - Returns: `[FieldsFormatter.Field]`
33+ open class func defaultFields( ) -> [ FieldsFormatter . Field ] {
34+ [
35+ . timestamp( style: . iso8601) ,
36+ . literal( " " ) ,
37+ . message( )
38+ ] . compactMap ( { $0 } )
39+ }
40+
41+ @available ( * , unavailable)
42+ public override init ( fields: [ FieldsFormatter . Field ] ) {
43+ fatalError ( " Use init(options:) for JSONFormatter " )
44+ }
45+
46+ }
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ extension OSLogTransport {
131131 /// - Parameters:
132132 /// - formatters: formatters to use. Ignore to use the default `XCodeFormatter`.
133133 /// - builder: builder configuration function.
134- public init ( formatters: [ EventMessageFormatter ] = [ XCodeFormatter . init ( ) ] ,
134+ public init ( formatters: [ EventMessageFormatter ] = [ OSLogFormatter . init ( ) ] ,
135135 _ builder: ( ( inout Configuration ) -> Void ) ? ) {
136136 self . formatters = formatters
137137 self . queue = DispatchQueue ( label: String ( describing: type ( of: self ) ) , attributes: [ ] )
You can’t perform that action at this time.
0 commit comments