Files
swift-log/Sources/Logging/Docs.docc/Reference/Logger.md
T
8ba97a9cf5 Update documentation to reflect recent changes (#445)
Update documentation to reflect recent changes

### Motivation:

The documentation was not updated in SLG-0003 or SLG-0005. Concretely,
the examples given in the documentation used the now deprecated
multiparameter methods in `LogHandler`, and the new `LogEvent`-based
method were not listed among the others. Likewise, the new logging
methods (`Logger.trace` etc.) that take an `Error` as a parameter were
not added. Lastly, `LogEvent` had no separate entry.
While the default rendered docs for these were acceptable, it decreased
the discoverability of the new methods, and the examples using
deprecated methods were misleading.

### Modifications:

* Update all code examples to use non-deprecated methods.
* List all new methods on `Logger` and `LogHandler` along the existing
ones.
* Add a minimal file for `LogEvent` to give it the same look as all
other types.
* Update code examples in `.md` files to follow swift format.

### Result:

Documentation reflects the current state and best practices of
`swift-log`.

---------

Co-authored-by: Joseph Heck <j_heck@apple.com>
Co-authored-by: Vladimir Kukushkin <kukushechkin@mac.com>
2026-04-17 09:12:32 +01:00

1.9 KiB

Logging/Logger

Topics

Creating Loggers

  • init(label:)
  • init(label:metadataProvider:)
  • init(label:factory:)-9uiy2
  • init(label:factory:)-6iktu
  • MetadataProvider

Sending trace log messages

  • trace(_:metadata:file:function:line:)
  • trace(_:metadata:source:file:function:line:)
  • trace(_:error:metadata:source:file:function:line:)

Sending debug log messages

  • debug(_:metadata:file:function:line:)
  • debug(_:metadata:source:file:function:line:)
  • debug(_:error:metadata:source:file:function:line:)

Sending info log messages

  • info(_:metadata:file:function:line:)
  • info(_:metadata:source:file:function:line:)
  • info(_:error:metadata:source:file:function:line:)

Sending notice log messages

  • notice(_:metadata:file:function:line:)
  • notice(_:metadata:source:file:function:line:)
  • notice(_:error:metadata:source:file:function:line:)

Sending warning log messages

  • warning(_:metadata:file:function:line:)
  • warning(_:metadata:source:file:function:line:)
  • warning(_:error:metadata:source:file:function:line:)

Sending error log messages

  • error(_:metadata:file:function:line:)
  • error(_:metadata:source:file:function:line:)
  • error(_:error:metadata:source:file:function:line:)

Sending critical log messages

  • critical(_:metadata:file:function:line:)
  • critical(_:metadata:source:file:function:line:)
  • critical(_:error:metadata:source:file:function:line:)

Sending general log messages

  • log(level:_:metadata:file:function:line:)
  • log(level:_:metadata:source:file:function:line:)
  • log(level:_:error:metadata:source:file:function:line:)
  • Level
  • Message
  • Metadata

Adjusting logger metadata

  • subscript(metadataKey:)
  • MetadataValue

Inspecting a logger

  • label
  • logLevel
  • handler
  • metadataProvider