Skip to content

Commit

Permalink
Update Logger.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Ignition committed Mar 23, 2024
1 parent 2cfbdc2 commit a8d8fda
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions Notes/Logger.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Logger

`Logger` - An object for writing interpolated string messages to the unified logging system.
`Logger` - An object for writing interpolated string messages to the unified logging system.

`Logger` and `OSSignposter` for Apple platforms

> [swift-log](https://github.com/apple/swift-log) Logger interface for different implementation for logging
Name | iOS | iPadOS | macOS | Mac Catalyst | tvOS | watchOS | visionOS
-------------|-----|--------|-------|--------------|------|---------|---------
OSLogStore | 15 | 15 | 10.15 | 15 | 15 | 8 | 1
OSSignposter | 15 | 15 | 12 | 15 | 15 | 8 | 1
Logger | 14 | 14 | 11 | 14 | 14 | 7 | 1
os_signpost | 12 | 12 | 10.14 | 13 | 12 | 5 | 1
os_log | 10 | 10 | 10.12 | 13 | 10 | 3 | 1

| Name | iOS | iPadOS | macOS | Mac Catalyst | tvOS | watchOS | visionOS |
| ------------ | --- | ------ | ----- | ------------ | ---- | ------- | -------- |
| OSLogStore | 15 | 15 | 10.15 | 15 | 15 | 8 | 1 |
| OSSignposter | 15 | 15 | 12 | 15 | 15 | 8 | 1 |
| Logger | 14 | 14 | 11 | 14 | 14 | 7 | 1 |
| os_signpost | 12 | 12 | 10.14 | 13 | 12 | 5 | 1 |
| os_log | 10 | 10 | 10.12 | 13 | 10 | 3 | 1 |

## Video

- WWDC23 [Debug with structured logging](https://developer.apple.com/wwdc23/10226)
- WWDC20 [Explore logging in Swift](https://developer.apple.com/videos/play/wwdc2020/10168/)
- WWDC18 [Measuring Performance Using Logging](https://developer.apple.com/videos/play/wwdc2018/405/)
- WWBD16 Unified Logging and Activity Tracing

## Customizing Logging Behavior While Debugging

[Customizing Logging Behavior While Debugging](https://developer.apple.com/documentation/os/logging/customizing_logging_behavior_while_debugging?language=swift) this documentation contains configuration for Mac OS applications only.
[Customizing Logging Behavior While Debugging](https://developer.apple.com/documentation/os/logging/customizing_logging_behavior_while_debugging?language=swift) this documentation contains configuration for Mac OS applications only.

The description of the setup for iOS can be read in the command `man 5 os_log`.
The description of the setup for iOS can be read in the command `man 5 os_log`.

> If the following OSLogPreferences dictionary were in the Info.plist of an application, it would enable all levels and persist the Info and Default levels for the "Details" category in the "com.example" subsystem; and it would enable signpost backtraces for the "Measurements" category.
Expand Down Expand Up @@ -51,12 +55,12 @@ The description of the setup for iOS can be read in the command `man 5 os_log`.

There are three levels for customizing behavior, but OSLogType has 5 types and Logger has 9 methods. It can be confusing. In order to understand them, a table is given below.

Level | OSLogType | Logger
--------|------------|--------------------
Default | `.fault` | `fault`, `critical`
Default | `.error` | `error`, `warning`
Default | `.default` | `log`, `notice`,
Info | `.info` | `info`
Debug | `.debug` | `debug`, `trace`
| Level | OSLogType | Logger |
| ------- | ---------- | ------------------- |
| Default | `.fault` | `fault`, `critical` |
| Default | `.error` | `error`, `warning` |
| Default | `.default` | `log`, `notice`, |
| Info | `.info` | `info` |
| Debug | `.debug` | `debug`, `trace` |

The table shows that 3 `OSLogType` are hidden behind the Default level. And thus it does not allow us to turn off all logs and show only errors. Because of this, try not to use `OSLogType.default` or methods `Logger.log(_:)`, `Logger.notice(_:)`.

0 comments on commit a8d8fda

Please sign in to comment.