You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,4 +120,23 @@ Then add `Logger` as a dependency for your targets:
120
120
- Add support for oslog in the framework. We currently support it in the ad-hoc callback. Add this to unit test as well as instructions on Console.app usage and limitations.
121
121
- Consider adding another log type called "important"
122
122
- Add usage gif exploring system console, google-analytics, xcode consol
123
-
- Add problem / solution to readme
123
+
- Add problem / solution to readme
124
+
- Add a note about apples OS.Logger. And its limitations.
// Creating a new DateFormatter every time a date is formatted can be expensive. Caching the DateFormatter instance using a lazy property improves performance.
* DateFormatter is used to format the date in the log.
36
39
* - Descriptino: It uses the dateFormat specified in the LogConfig, sets the timezone to UTC, and sets the locale to "en_US_POSIX".
@@ -40,11 +43,16 @@ extension LogConfig {
40
43
* - Note: In the context of the LogConfig struct, the en_US_POSIX locale is used to ensure that the date and time formatting is consistent regardless of the user's locale settings
41
44
*/
42
45
vardateFormatter:DateFormatter{
43
-
letformat:DateFormatter=.init() // Create a new DateFormatter instance
44
-
format.dateFormat = dateFormat // Set the date format to the specified format
45
-
format.timeZone =TimeZone(identifier:"UTC") // Set the time zone to UTC
46
-
format.locale =Locale(identifier:"en_US_POSIX") // Set the locale to US English
47
-
return format // Return the DateFormatter instance
46
+
iflet formatter =Self.cachedDateFormatter {
47
+
return formatter
48
+
}else{
49
+
letformat=DateFormatter()
50
+
format.dateFormat = dateFormat
51
+
format.timeZone =TimeZone(identifier:"UTC")
52
+
format.locale =Locale(identifier:"en_US_POSIX")
53
+
Self.cachedDateFormatter = format
54
+
return format
55
+
}
48
56
}
49
57
}
50
58
// Extension of LogConfig for predefined configurations.
0 commit comments