Compare commits

..
263 Commits
Author SHA1 Message Date
Johannes Weiss ce592ae52f remove superfluous whitespace (#366)
### Motivation:

`StreamLogHandler` has at some point in time acquired an extra
whitespace:

```
2025-07-18T10:09:12+0100 notice label : hello
                                     ^
                                     |
                                     this one is superfluous
```

but we don't typically put spaces in front of `:`s. This PR changes it
to

```
2025-07-18T10:09:12+0100 notice label: hello
                                     ^
                                     |
                                     no extra space
```

Additionally, if the label is empty (`""`), then we shouldn't print any
spaces there. So with an empty label, we go from

```
2025-07-18T10:09:12+0100 notice  : hello
                               ^^
                                |
                                two superfluous spaces
```

to

```
2025-07-18T10:09:12+0100 notice: hello
                               ^
                               |
                               no extra spaces
```



### Modifications:

- Remove superfluous space if label is not empty
- Remove two superfluous spaces if label is empty

### Result:

- Somewhat more compact output
- Nicer output
2025-07-18 09:27:45 +00:00
Si Beaumont e1600be8ec Fix broken link to documentation on README (#365) 2025-07-17 09:08:32 +00:00
Franz Busch cbd28c274b Add an article how to implement a log handler (#364)
# Motivation

In my previous PR, I overhauled the README and the DocC catalog. While
doing this I removed the guidance around how to implement a log handler.

# Modifications

This PR adds a DocC based guide containing the contents of the previous
README guidance.

# Result

Guidance around log handler implementation in a modern DocC format.
2025-07-09 19:06:26 +02:00
Franz Busch c05d67286c Overhaul README and documentation catalog to introduce best practices (#363)
# Motivation

`SwiftLog` was created before DocC existed which meant that most of the
documentation was part of the `README` and we had a pretty bare bones
documentation catalog. We also have a second source of guidelines from
the SSWG. This results in a currently unsatisfying developer experience
where everyone has to go around looking for the content in mostly
undocumented places.

# Modifications

This PR overhauls the `README` and moves most of the content into the
documentation catalog. It also introduces a new section called "Best
practices" that are intended to replace the logging guides on swift.org
so that the content moves closer to where it belongs. To showcase such a
best practice this PR brings over the log level recommendation of
swift.org. The recommendation is mostly the same except that after
recent discussions we wanted to allow libraries to log at `info` level
when they encounter problems which they can't communicate through other
channels e.g. by throwing from a method.

# Result

With this PR we provide a nicer experience to our developers making it
easier for them to get started and understand how to properly log. We
also set ourselves up for expanding on the best practices around
logging.
2025-07-09 16:48:56 +02:00
Gwynne RaskindandFranz Busch 2281e43060 Remove inaccurate code comment (#349)
Remove an inaccurate comment from the code.

### Motivation:

The removed comment incorrectly described the `flush()` method as not
having an effect when the flush mode is set to `.always`. Not only is
this the opposite of the actual behavior, in fact the method itself is
not affected by the flush mode at all; that check is made elsewhere.
Further, at the point where the check is made, the behavior is clearly
spelled out by the code making the check, so moving the comment there
seems redundant. As such, it seemed best to simply remove it altogether.

### Modifications:

Removed a comment.

### Result:

The inaccurate comment can no longer cause confusion.

Co-authored-by: Franz Busch <f.busch@apple.com>
2025-07-08 19:12:15 +00:00
Rick Newton-Rogers 81d3d07f14 Enable Swift 6.1 jobs in CI (#359)
Motivation:

Swift 6.1 has been released, we should add it to our CI coverage.

Modifications:

Add additional Swift 6.1 jobs where appropriate in main.yml,
pull_request.yml

Result:

Improved test coverage.
2025-04-14 12:15:58 +02:00
Rick Newton-Rogers 09c99dd25a Add static SDK CI workflow (#355)
Add static SDK CI workflow which runs on commits to PRs, merges to main
and daily on main.
2025-04-02 13:41:15 +00:00
Marc Prud'hommeaux 748d1eb5d9 Android test fixes (#356) 2025-04-01 10:35:06 +00:00
Rick Newton-Rogers 765db8bc47 Enable macOS CI on pull requests (#358)
Motivation:

* Improve test coverage

Modifications:

Enable macOS CI to be run on pull request commits and make the use of
the nightly runner pool for main.yml jobs explicit.

Result:

Improved test coverage.
2025-04-01 12:25:50 +02:00
Rick Newton-Rogers 222bf1b48b Enable macOS CI on merge to main and daily timer (#357)
Motivation:

* Improve test coverage
* Check test pass/fail status
* Monitor CI throughput

Modifications:

Enable macOS CI to be run on all merges to main and on a daily timer.

Result:

Improved test coverage run out-of-band at the moment so we can get a
feeling for if any changes need to be made in the repo or in the CI
pipelines to ensure timely and stable checks.
2025-03-31 13:29:37 +01:00
Honza Dvorsky 3d8596ed08 Fix building on Fedora 39 and Ubuntu 24.04 (#354)
### Motivation:

Fixes https://github.com/apple/swift-log/issues/278.

### Modifications:

Fixed tests to successfully compile on Fedora 39 and Ubuntu 24.04, which
they previously failed on.

### Result:

Ability to run tests on these two platforms again.
2025-03-12 11:48:26 +00:00
Rick Newton-Rogers 3a9d8c908f Only apply standard swift settings on valid targets (#353)
Only apply standard swift settings on valid targets. The current check
ignores plugins but that is not comprehensive enough.
2025-03-07 19:35:11 +01:00
Rick Newton-Rogers 2dd04b00f4 Rename nightly_6_1 params to nightly_next (#352)
Rename nightly_6_1 params to nightly_next; see
https://github.com/apple/swift-nio/pull/3122
2025-03-04 10:38:13 +00:00
Rick Newton-Rogers 770059c51d CI use 6.1 nightlies (#348)
CI use 6.1 nightlies now that Swift development is happening in the 6.1
branch
2025-01-31 09:58:02 +00:00
Luke Howard f82ce9631f Add swift-log-systemd has moved (#345) (#346)
swift-log-systemd has been merged into the umbrella swift-systemd
package
2025-01-12 11:59:36 +01:00
9576fd5710 fix: fix typo (#333)
Co-authored-by: Sunset Wan <sunset.wan@assaabloy.com>
Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2025-01-07 11:06:00 +00:00
Luke Howard 8f746b0f16 Add swift-log-systemd.git to the list of available backends (#345) (#345)
systemd-based log integration

### Motivation:

Using native backend for storing log data

### Modifications:

Add swift-log-systemd to the list of available backends

### Result:

Another one option to use the package with
2025-01-07 10:45:11 +00:00
Franz Busch 6efb781a29 Update release.yml (#344)
Update the release.yml file with the latest label changes
2024-12-18 14:18:53 +01:00
Rick Newton-Rogers 9e1494a076 Enable MemberImportVisibility check on all targets (#343)
Enable MemberImportVisibility check on all targets. Use a standard
string header and footer to bracket the new block for ease of updating
in the future with scripts.
2024-12-11 10:51:35 +00:00
Honza Dvorsky 960b23e33f Enable strict concurrency (#342) 2024-11-29 23:27:51 +01:00
Luke Howard 18cc7907d6 Add AndroidLogging to the list of available backends (#340)
Add AndroidLogging to the list of available backends.
2024-11-29 11:46:44 +00:00
Franz Busch 9bc47c93fa Aligning semantic version label check name (#341) 2024-11-28 13:00:19 +01:00
Mikhail Kasianov 96a2f8a0fa Add Scout to the list of available backends (#337)
* Add Scout to the list of available backends

* Update README.md
2024-11-25 17:24:15 +00:00
Rick Newton-Rogers 0e75c43ee4 add .editorconfig file (#338) 2024-11-14 17:01:02 +01:00
LamTrinh.Dev 5f816304f9 Enhance swift codeblock at README.md (#327) 2024-11-13 13:38:45 +00:00
Franz Busch 1efe6f8129 Fix Windows warnings (#331)
# Motivation

Fixes https://github.com/apple/swift-log/issues/330.

We had a few warnings since we were using deprecated POSIX methods on Windows.

# Modification

Moves to the non-deprecated underscored methods.

# Result

Windows build is warning free.
2024-10-31 11:55:18 +01:00
Franz Busch ee1bfd3f47 [CI] Migrate to GHA (#328)
# Motivation

We want to modernize our CI.

# Modification

This PR migrates to GH actions and turns on all the right flags.

# Result

Modern CI.
2024-10-30 13:17:15 +00:00
LamTrinh.Dev da3fdd167f Correct the link of incubation-process at README.md (#326) 2024-10-09 00:22:10 -07:00
Alex Lorenz d03205626d add android support (#325) 2024-10-01 08:23:03 +09:00
LamTrinh.Dev 2cb03fa60e Correct the link of sswg-security at SECURITY.md (#318) 2024-09-19 02:00:49 -07:00
b1ackturtle db86ac725b Fix compile warnings for Swift 6 language mode (#313) 2024-06-25 11:53:51 -07:00
George Barnett 9cb486020e Disable existential any build setting (#312)
Motivation:

On 5.8, if the experiment existential any setting is enabled and a
consuming package holds an existential of a type from swift-log without
an explicit 'any' then the build will fail.

Modifications:

- Disable the setting

Result:

Users of 5.8 aren't broken
2024-06-24 18:21:21 +01:00
elishas b3a6373077 Update README.md add shipbook as backend (#304)
Motivation:

Added shipbook as backend for the library.

Modifications:

Just added it to the backend list.

Result:

Will have a fuller list.
2024-06-20 05:18:55 -07:00
Ross Butler 4bcd3dfb11 Added swift-log-ecs to README.md (#298) 2024-06-19 10:06:47 +01:00
Peter Adams 7adcf9aa15 Remove Docc plugin which is no longer required. (#311)
Motivation:

Plugin is no longer required to produce docs.
There are now warnings in the plugin when included
and it will delay build a small amount.

Modifications:

Remove plugin dependency.

Result:

No dependencies.
2024-06-19 09:27:12 +01:00
Peter Adams f5312694b3 Fix deprecation warnings around default log implementations on handlers (#310)
Motivation:

Latest swift introduces new warnings when deprecated default
implementations are used.

Modifications:

Add new log implementation to NoopLogHandler.
Mark test of old method as deprecated to silence warning.

Result:

Warning free builds on latest swift 6 compiler.
2024-06-19 05:19:26 +01:00
Peter Adams 6553ef5893 Add Sendability annotations (#308)
Motivation:

This becomes a critical feature in swift 6.

Modifications:

Add Sendability annotations where required.
Factor out code protected by locks.

Result:

Compiles without warnings with Sendability checking
2024-06-18 08:28:58 -07:00
b1ackturtle 11e749ea6d Remove documentation for non-existent arguments (#309) 2024-06-17 02:16:17 -07:00
Peter Adams d16e216341 Make protocol usage obvious using any and some keywords (#307)
Motivation:

Calling through protocols is more expensive than many other types of call.

Modifications:

Annotate each protocol usage with any or some keywords.

Result:

Protocol usage now obvious
2024-06-10 15:16:46 +01:00
Peter Adams 0f170b4764 Use Set to spot duplicated log handler warnings. (#306)
Motivation:

Feels like a better fit for the problem when a dictionary of bools.

Modifications:

Convert storage to set.

Result:

Fewer lines of code, less waste.
2024-06-10 14:17:43 +01:00
23517234d5 feat: Implement Copy-On-Write (CoW) behavior for Logger struct (#297)
* feat: Implement Copy-On-Write (CoW) behavior for Logger struct

* fix: refactored the struct and added test

* fix: refactored the struct

* fix: refactored the struct

* fix:Added compiler directive and @usableFromInline/@inlinable

* fix: Add endif label

* fix: Remove colon causing expected type

* fix: Add inlinable and moving compiler derective

* nit

* fix: add inlinable

* Update Sources/Logging/Logging.swift

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>

* Update Sources/Logging/Logging.swift

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>

* Update Sources/Logging/Logging.swift

Co-authored-by: Franz Busch <privat@franz-busch.de>

* Update Sources/Logging/Logging.swift

Co-authored-by: Franz Busch <privat@franz-busch.de>

* fix: add self to class declaration and fixed formatting

* fix: make label public

* fix: format

* fix: remove setter

* test: added a test case

---------

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Franz Busch <privat@franz-busch.de>
2024-05-30 11:18:30 +01:00
Gustavo Cairo c7dcb55fb9 Drop Swift versions earlier than 5.8 (#299)
* Drop Swift versions earlier than 5.8

* Delete build_podspec.sh

* Update check_no_api_breakages script
2024-05-16 10:11:40 +01:00
Franz Busch ebb05e0317 Remove archived repository (#292)
https://github.com/luoxiu/LogDog appears to be archived.
2024-05-09 13:42:36 +01:00
Ayushi Tiwari b1617b3c0c feat: Replace standardOutput to standardError (#295) 2024-05-09 14:21:58 +02:00
Yim Lee c1ff8be7bc Add CI for Swift 5.10 (#287) 2024-01-23 08:24:18 -08:00
Alastair Houghton e97a6fcb1a Changes to build with Musl. (#283)
Added imports of Musl in a few places.  Also added definitions
for `systemStderr` and `systemStdout`.
2023-12-07 10:42:43 -08:00
Tim Condon 4587ac512c Update README.md (#279)
Improve the README to make it easier to find different logging backends
2023-11-24 12:17:59 +09:00
Gwynne Raskind f447991bd2 Don't assume localtime() result is non-nil (#280)
Don't assume localtime() result is non-nil
2023-11-16 16:15:22 -08:00
tomer doron 86ee8ef09e update CI script (#281)
motivation: fix CI

* do not install ruby or jazzy, they are no longer needed
* remove documentation generation script
2023-11-17 07:30:57 +09:00
Florian Friedrich cb28750240 Add CocoaLumberjack to list of logging backends (#276) 2023-08-23 09:46:39 -07:00
Fanny 532d8b5295 docs: fix typo (#272) 2023-08-10 23:30:58 -07:00
Kilian KoeltzschandKonrad `ktoso` Malawski f8ce47d3b0 add kiliankoe/swift-log-matrix to list of backends (#263)
Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2023-06-26 06:31:42 -07:00
Mahdi BahramiandKonrad `ktoso` Malawski 1ef0345e1e Fix DiscordLogger link (#266)
Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2023-06-23 13:54:15 +09:00
Franz Busch 5996c7a1b4 Use #if canImport(Darwin) where possible (#269) 2023-06-21 10:53:31 -07:00
tomer doron 1aacf8affa update code of conduct (#268)
motivation: align CoC across the swift project

changes: change CoC to link to the swift.org version
2023-06-06 10:24:05 -07:00
Yim Lee bd5ff0d8e4 Update CI (#264)
- Swift 5.8 docker images are available
- Add docker-compose file for Swift 5.9
2023-04-04 20:21:17 -07:00
Mahdi BahramiandKonrad `ktoso` Malawski f79ba6a75f Add DiscordBM/DiscordLogger to loggers list (#257)
* Add DiscordBM/DiscordLogger to loggers list

Adds [DiscordBM](https://github.com/MahdiBM/DiscordBM/blob/discord-logger/README.md#discord-logger) to the logger list.

The description is:

> a Discord package containing a standalone [DiscordLogger library](https://github.com/MahdiBM/DiscordBM/blob/discord-logger/README.md#discord-logger)

Please do tell if you think "standalone" is misleading 🤔 I'm just trying to imply that users don't need to depend on the full package just for Discord-logging.

Resolves #256

* Update README.md

---------

Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2023-02-12 17:56:04 -08:00
Konrad `ktoso` Malawski 6763fd0b73 Remove leftover 5.0 Package.swift; not supported since 1.5.0 (#259) 2023-01-31 22:27:53 +09:00
Yim Lee 32e8d72446 Add CI for Swift 5.8 and update nightly to Ubuntu 22.04 (#255) 2023-01-24 10:41:01 +09:00
Konrad `ktoso` Malawski b2eff1c427 Handle providers properly in multiplex log handler (#254)
Co-authored-by: Moritz Lang <hi@slashmo.codes>
Resolves https://github.com/apple/swift-log/issues/253
2023-01-24 10:10:39 +09:00
Konrad `ktoso` Malawski ba2a9f5b93 Avoid logging warnings when handler does not support metadataproviders (#252) 2023-01-23 23:58:13 +09:00
Moritz LangandKonrad `ktoso` Malawski 3e3ef75109 Emit correct metadata from StreamLogHandler (#251)
Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2023-01-19 05:41:36 +09:00
Konrad `ktoso` MalawskiandYim Lee bd4519f1c2 Allow passing explicit provider into the stream handlers (#250)
Co-authored-by: Yim Lee <yim_lee@apple.com>
2023-01-18 12:32:30 -08:00
e6ca651cbc Metadata Providers (e.g. for Distributed Tracing) in LogHandlers (#238)
Co-authored-by: Moritz Lang <hi@slashmo.codes>
Co-authored-by: Yim Lee <yim_lee@apple.com>
2023-01-18 16:23:37 +09:00
Timo Boll dc77805fdc Fixes link to Supabase repository (#245) 2023-01-05 16:32:24 -08:00
Yim Lee e979c6945c Add .spi.yml for Swift Package Index DocC support (#240) 2022-12-01 21:41:27 -08:00
Lukas d86803715f Fix build for wasm (#236)
Seems like a few places were missed in the locking refactor, which made the WASM build fail
2022-11-02 11:00:11 -07:00
Ruslan Kavetsky f7b7977065 Update README.md (#233) 2022-09-17 15:00:35 +09:00
Konrad `ktoso` Malawski ce09fe6dac Undo 5.7 package files, not needed yet (#232)
* Undo 5.7 package files, not needed yet

* no need for xcrun in docs preview script
2022-08-24 12:33:23 +09:00
Konrad `ktoso` Malawski a8e1148aa5 =docc Move to multiple Package.swift files (#231)
* +docc prepare for docc docs

* fix syntax in one of the package files

* ignore package.resolved
2022-08-23 18:29:56 +09:00
Konrad `ktoso` Malawski 483e2bbcdd =docc Make docs use symbol references (#230) 2022-08-23 17:11:11 +09:00
Konrad `ktoso` MalawskiandYim Lee d5bf59c6b2 [docs] Minimal docc setup and landing page (#226)
* [docs] Minimal docc setup and landing page

* move index file

* Update Sources/Logging/Logging.swift

Co-authored-by: Yim Lee <yim_lee@apple.com>

Co-authored-by: Yim Lee <yim_lee@apple.com>
2022-08-23 16:08:28 +09:00
Konrad `ktoso` Malawski 6fe203dc33 [sendable] MetadataValue conformance must be unchecked on 5.6 now 2022-08-15 09:19:49 +09:00
Konrad `ktoso` Malawski 6b0ccb1ca8 [sendable] Sendable conformance checks cause errors on 5.6 but warnings on 5.7 2022-08-15 09:19:49 +09:00
Joseph HeckandKonrad `ktoso` Malawski 8fc79cae9d minimal DocC markdown to order Logger.Levels (#225)
* minimal DocC markdown to order Logger.Levels

Motivation:

When viewed in documentation generated by DocC, the enumeration levels
are ordered alphabetically, removintg the implied ordering in the
source. The written overview of the enum relies on that ordering to make
sense.

Modifications:

Adding a single file that provides structure to Logging/Logger/Levels
within DocC generated documentation.

Result:

When imported into a project that leverages Swift 5.6 (such as Vapor),
the generated documentation for the levels provided by
Logging/Logger/Levels are displayed in the order intended/expected by
the documentation.

* Adding a Swift 5.6 version of Package.swift

Motivation:

Per DocC team, an updated version is required for the DocC changes
to be picked up and reflected in generated dcumentation, even for
upstream projects already using swift 5.6 or later.

Modifications:

Adding Package.Swift@5.6 with the swift version updated.

Result:

Hopefully, documentation updates in DocC generated content will be
reflected.

* Updating linuxmain test generation for <swift5.6

Motivation:

To appease CI, added #if statements into generated LinuxMain
content to handle conditional compilation with Swift 5.6 and later.

Modifications:

Added #if statements to test generating script and re-ran the script

Result:

CI will hopefully pass.

* also guard the LinuxMain file

* Force using test discovery on 5.6+ even though tools version is latest
but LinuxMain exists

* cleanup

* simplify docc links

* formatting revert

* ignore Package-swift5.6.swift from soundness license check

Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2022-07-20 14:38:17 +09:00
tomer doron f2e8667d50 adopt sendable (#218)
motivation: adjust to swift 5.6

changes:
* define sendable shims for protocols and structs that may be used in async context
* adjust tests
* add a test to make sure no warning are emitted
2022-07-01 16:38:19 -07:00
tomer doron 9f3731aa55 better abstration for LoggingSystem state (#222)
motivation: prepare for sendable checks

changes:
* abstract the LoggingSystem state into a "boxed" class that handles the locking
* adjust call sites
2022-06-29 11:07:50 -07:00
Guilherme Souza 2bf6215b68 Add binaryscraping/swift-log-supabase to README (#221) 2022-05-10 11:39:59 -07:00
tomer doron 432a93204e ci update (#219)
motivation: 5.6 is out

changes:
* use release version of 5.6
* add docker setup for 5.7 (using nightly for now)
2022-03-16 21:04:07 -07:00
Cory Benfield dc6dd5caaa Add 5.6 nightly CI (#214)
The 5.6 nightly images are available, let's use them.
2022-01-18 10:03:36 -08:00
tomer doron 5db2bc495a update doc generation script (#213)
motivation: source-kitten has changed how its invoked

changes:
* invoke source-kitten with the correct flags
* make location of source-kitten source checkout more robust
2021-12-16 15:18:06 -08:00
Andriy Druk 4e75f88c6a Add Android support (#209) 2021-10-26 16:20:20 -07:00
tomer doron 77192b9e21 add docker setup for 5.5 (#211)
motivation: ci on 5.5

changes: add docker setup for 5.5
2021-10-18 15:15:28 -07:00
tomer doron b172d1ae3d fix jazzy issues on older versions of ubuntu (#210) 2021-10-18 15:03:31 -07:00
Shiva HuangandKonrad `ktoso` Malawski a7e6d7fef5 Add swift-log-SwiftyBeaver as a new logging backend to the Readme (#203)
Co-authored-by: Konrad `ktoso` Malawski <ktoso@apple.com>
2021-08-10 16:34:45 +09:00
Philipp, Zagar 9cdea8c2af Add swift-log-elk to Readme (#201) 2021-08-10 16:30:26 +09:00
Saleem Abdulrasool d8af258aec Tests: enable tests on Windows (#198)
This adds support for running the tests on Windows.  However, running
the tests on Windows requires SPM currently.  While it is possible to
enable executing tests with CMake, the expectation is that SPM builds
would be the most common and CMake is largely used for bootstrapping.
The changes here require alterations to remove the POSIX threading to
get the thread ID.  Additionally, pipes on Windows are not similar to
pipes on Unix platforms. Finally, we must add Windows to the platform
list, which is temporary (it would be better to use test discovery in
SPM).
2021-06-15 06:25:41 +09:00
Saleem Abdulrasool 02770d91fc Logging: avoid a deprecation warning on Windows (#199)
Windows recommends the safety extension usage which in this case
explicitly allow you to be informed of failures.  This just avoids an
annoying warning when using logging in projects.
2021-06-14 21:05:34 +09:00
Johannes Weiss 7ebe44cb03 adopt security guidelines (#197) 2021-06-09 10:18:03 +01:00
tomer doron 65a8e5e921 update 5.4 to release docker image (#196)
motivation: 5.4 is out!

changes: use release docker images instead of nightly
2021-05-06 18:07:14 -07:00
George Barnett 08ec50d7b1 Add SwiftLogNoOpLogHandler.init(_: String) (#194)
Motivation:

`LogHandler` facotories are given a label as input and return a
`LogHandler`. Since the no-op handler doesn't care about the label
callers must provide a thunk: `{ _ in SwiftLogNoOpLogHandler() }`.
That's fine but slightly more annoying to type than it needs to be.

Modifications:

- Add `SwiftLogNoOpLogHandler.init(_: String)`

Result:

Users can create a logger with the no-op handler with:

```swift
Logger(label: "foo", factory: SwiftLogNoOpLogHandler.init)
```

instead of:

```swift
Logger(label: "foo", factory: { _ in SwiftLogNoOpLogHandler() })
```
2021-05-05 19:02:50 +09:00
Johannes Weiss 3577a992d3 use #fileID for Swift 5.3+ (#187)
Motivation:

Right now, we use the full path (`#file`) for the logging as well as for
parsing out the module name (which goes into `source` by default).

This has two problems:

1. The file names contain the build server's full path, ie. aren't
   portable across different compiles (and are very long).
2. The module name parsing fails if we log from a file that's not in a
   directory named just like the module.

Modification:

Switch `#file` for `#fileID`. This changes a bunch of things:

- `source` is always the module name by default (great!)
- `file` changes from `/the/full/path/on/disk` to `ModuleName/FileBaseName.swift` (I think better, but it's a change)

Result:

`source` is more correct, `file` will be different.
2021-04-06 14:28:43 +01:00
felipejinliandJohannes Weiss b1d1c0372a Improve StdioOutputStream with fwrite (#180) (#188)
Replaced `fputs` with `fwrite`, added test and made spelling corrections

Motivation:

If a 0 byte is logged, `fputs` would not output the content after the 0 byte making it harder to debug (see #180). `fwrite` uses a count argument so content after 0 byte can be logged.

Modifications:

Replaced `fputs` with the correct call to `fwrite`.   Added helper internal func `contiguousUTF8(_ string: String) -> String.UTF8View`. Added `testStdioOutputStreamWrite()` to test ability to log content after 0 byte.

Result:

Improved debugging experience

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2021-04-06 14:19:35 +01:00
Moritz Lang bc049d05d0 Include source in StreamLogHandler output (#189)
Motivation:

When using the same Logger across an application in combination
with the default StreamLogHandler, it may be difficult to differentiate
between logs produced by different modules. ServiceLifecycle works around
this by prepending the log message with [Lifecycle], which is what I'd like
to do StreamLogHandler by default, leveraging the source log parameter.

Modifications:

StreamLogHandler will include the source in brackets right before
the log message when writing a log.

Result:

Logs from different modules are easily differentiable when produced
using the same Logger instance.
2021-04-06 21:41:35 +09:00
Peter Steinberger bda2661797 Remove references to Swift 4 (#186)
I found https://github.com/apple/swift-log/releases/tag/0.0.0 however these are just shims.
Seems unlikely that this is still needed.
2021-03-05 08:32:41 +09:00
Saul Baro Ruiz 5d66f7ba25 Fix function being dropped on source-less trace (#185)
Motivation:

When using the recently re-introduced source-less version of trace, the function parameter that reaches the underlying LogHandler is wrong.

Modifications:

Pass the function parameter to trace with source parameter.

Result:

With these changes, the function parameter that reaches the underlying LogHandler has the correct value.
2021-03-03 14:35:32 +09:00
tomer doron c7988420c2 add docker setup for 5.4 and nightly (#183)
motivation: CI for 5.4 and latest

changes: add docker setup files for 5.4 and main nightly images
2021-02-27 10:58:11 +09:00
Johannes Weiss 7d1d4e29ea drop Swift 4.x info from the readme (#182) 2021-02-26 06:16:35 +09:00
George BarnettandKonrad `ktoso` Malawski 12d3a8651d Add back accidentally removed API (#152)
Motivation:

- When `source:` was added in #135, the API was accidentally broken
  despite source compatability.

Modifications:

- Add back source-less API calls which defer to the decls with source.
- Note we can't deprecate the calls we're adding back:
  `log.info("some message")` refers to the implementation we're adding
  back rather and would therefore require users to explicitly specify a source
  to suppress the deprecation warning message.

Result:

- API is no longer broken.

Co-authored-by: Konrad `ktoso` Malawski <ktoso@apple.com>
2021-02-22 18:56:48 +09:00
Helge Heß b5440510b6 Add support for logging in SwiftWasm (via WASILibc) (#177) 2021-01-25 21:59:17 +09:00
Yim Lee c6437b76d8 Use welcoming language (#178) 2021-01-22 00:43:26 -08:00
Hassan ElDesouky 16cfcc60e4 [Logging] Gardening: correct a comment spelling (#174)
Change `It it acceptable` to `It is acceptable`.
2020-12-23 22:17:47 +09:00
Doug Pedley 974b90e008 Added dependency update for Swift 5.2 (#173) 2020-12-16 08:53:38 +09:00
Luo Xiu cb77380f88 add luoxiu/LogDog (#170) 2020-11-19 04:09:00 +09:00
Koichi Yokota 7bc87ea4ca Add sushichop/Puppy to list of backends (#169) 2020-11-13 09:47:14 +09:00
Mathieu Barnachon 04b23c1c17 Update the name and URL of Helium logger after moving to a community project. (#168) 2020-10-27 21:31:25 +09:00
Saleem Abdulrasool 5fa4a664a0 Logging: repair the Windows build after MSVCRT rename (#167)
Import `CRT` instead of `MSVCRT`.
2020-10-23 02:10:43 +09:00
tomer doron 6a1fd374f8 remove symbolicate-linux-fatal from Docker (#166)
motivation: we are not actually using symbolicate-linux-fatal in any meaningful way in CI and it's pinned to the master branch which has been removed

changes: remove symbolicate-linux-fatal fetching from Docker
2020-10-07 16:47:02 -07:00
Christopher PrinceandKonrad `ktoso` Malawski 4a0205445c Add a simple local file-based logger. (#165)
* Update README.md

* Update README.md

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2020-10-07 16:18:55 +09:00
tomer doron b8eedd521d Swift 5.3 was released, use if for CI (#161)
motivation: Swift 5.3 was released, use if for CI

changes: update docker setup to use the release version of 5.3
2020-09-20 12:08:38 +09:00
Konrad `ktoso` Malawski 5a1b9cfc71 Change link to point at main branch (#159) 2020-09-08 14:55:24 +09:00
Tim Wise 1d40828ecc Added SwiftLogFireCloud to available logging impls. (#158)
* Adding SwiftLogFireCloud to table of available backends
2020-09-04 01:50:40 +09:00
George Barnett a4aa2d5bd9 Sort metadata by keys when prettifying
Motivation:

The stream log handler doesn't print metadata in a stable order. While
swift-log is an API package and shouldn't provide all the bells and
whistles for formatting logs, it should make the default log handler
at least somewhat sensible.

Modifications:

- Sort the metadata by key when 'prettifying' it

Result:

- The stream log handler emits logs with metadata in a stable order
- Resolves #128
2020-09-04 01:45:19 +09:00
Alexey Demin de30f5bfc2 Update README.md 2020-07-31 11:14:02 +09:00
Konrad `ktoso` Malawski dc3970db38 Update CONTRIBUTING.md 2020-07-18 12:23:25 +09:00
Konrad `ktoso` Malawski a885be7bff add info about sanity.sh 2020-07-18 12:23:25 +09:00
Adam Fowler 173f567a2d Make SwiftLogNoOpLogHandler.init() public 2020-07-08 13:05:43 +09:00
Konrad `ktoso` Malawski 57c6bd0425 =doc #82 avoid showcasing internal lock in public docs 2020-07-07 03:12:19 +09:00
Konrad `ktoso` Malawski 024f44d4d5 -log remove the LoggerWithSource for the time being 2020-07-06 20:01:11 +09:00
Johannes Weiss c37c434930 add source for log messages 2020-07-06 20:01:11 +09:00
0c61f3610d =multiplex #139 more properly handle logLevel in multiplex handler (#140)
* =multiplex #139 more properly handle logLevel in multiplex handler

* swift 5.0 needs explicit return

* no need to loop over the settings

* =metadata MultiplexLogHandler now consistently handles metadata read/write

* Apply suggestions from code review

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbrntt@gmail.com>

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbrntt@gmail.com>
2020-07-06 18:34:43 +09:00
Adam Fowler 237094d249 Add NoOpLogHandler for when you don't want logging (#142)
* Add NoOpLogHandler for when you don't want logging

* Make NoOpLogHandler functions @inlinable

* Renamed to SwiftLogNoOpLogHandler
2020-07-02 20:54:26 +09:00
Gwynne Raskind 2caaa7fc10 Improvements to Lock and ReadWriteLock, and PTHREAD_MUTEX_ERRORCHECK (#141)
* Update comments in Locks.swift to correctly reflect the Windows implementation and to correctly describe the operation of the `ReadWriteLock`.

* Add error messages to the preconditions on pthread function call return values. Copied from NIO's `Lock` implementation.

* In `Lock`, create the underlying mutex (where applicable) using `PTHREAD_MUTEX_ERRORCHECK`. Copied from NIO's `Lock` implementation. Performance loss is minor on Xenial, Bionic, CentOS, and AmazonLinux; no loss was measurable on Focal at all.

* On Windows, correctly set the `shared` flag in `ReadWriteLock` so the correct `ReleaseSRWLock*()` function is called in `unlock()`. It appears that in practice Windows does not actually care whether the correct release function is called for the type of lock the thread was holding, but this is undocumented (along with most other semantics of `SRWLOCK`) and thus can not be relied upon.

* Fix formatting (that's what I get for copy-pasting from NIO verbatim)
2020-06-30 16:10:18 +09:00
Johannes Weiss afc50b29de forward #file to #filePath differently (#137)
Motivation:

only works if done when _calling_ a function, not when defining one :|.

- https://github.com/apple/swift/pull/32445
- https://bugs.swift.org/browse/SR-12936
- https://bugs.swift.org/browse/SR-12934
- https://bugs.swift.org/browse/SR-13041

Modifications:

Silence #file to #filePath differently.

Result:

Hopefully at some point we get this working.
2020-06-22 11:47:59 +01:00
Johannes Weiss ee8b3c5044 silence #file to #filePath warnings (#133)
Motivation:

Swift 5.3 will keep `#file` == `#filePath` but starts warning if you
pass `#file` to an argument that's `#filePath` defaulted (XCTest).

Modification:

- Replace `#file` with `(#file)` to silence the warning. In Swift 5.3
  `#file` == `#filePath`.

Result:

No warnings
2020-06-09 11:16:12 +09:00
Shiva HuangandShiva Huang 6d233ae476 Fix doc typo (#134)
* Fix typo in "MetadataValue" words in docs

* Fix typo in "bootstrap" words in docs

Co-authored-by: Shiva Huang <shiva.huang@ailabs.tw>
2020-06-08 13:28:23 +09:00
Jeremy Greenwood a9784b00a6 add swift-log-datadog to list of backends (#132) 2020-06-02 08:28:20 +09:00
tomer doron 4f87671873 improve 5.3 docker setup (#131)
motivation: pin to 5.3 nighties 

changes: use swiftlang/swift:nightly-5.3-master-bionic instead of swiftlang/swift:nightly-master-bionic
2020-05-05 11:07:38 +01:00
zach wick 87c2553da2 Updates the docstring for the 'trace' log level (#130)
Motivation:

The current docstring seems to be missing some words that indicate
when a 'trace' log level is more appropriate than a 'debug' log
level. This was brought up in https://github.com/vapor/docs/issues/463
and has been fixed there. This PR is being submitted to the upstream
project as a courtesy.

Modifications:

This PR adds a clause to the docstring of the 'trace' log level to
clearly indicate when this log level shuld be used.

Result:

The docstring for the 'trace' log level will mirror the structure of
the docstring for the 'debug' log level, but will include a clear
opinion of when the 'trace' log level is appropriate.

Signed-off-by: zach wick <zach@zachwick.com>
2020-05-04 09:27:54 -07:00
YR Chen c08d7f72b9 add stevapple/swift-log-telegram to list of backends (#129) 2020-04-11 11:57:42 +01:00
Mattt da2c8aa854 Add NSHipster/swift-log-github-actions to list of backends (#124) 2020-04-04 09:51:35 -07:00
tomer doron fa15ddefc4 update ci setup (#127)
motivation: 5.2 adoption, prepare for 5.3

changes:
* add 5.2 docker-compose setup
* add 5.3 docker-compose setup (placeholder)
* fix formatting
2020-04-04 00:20:45 -07:00
Tanner 8ede07bf98 Add easy link to backends section (#125)
* Update README.md

* Update README.md

* Update README.md
2020-04-02 08:33:44 +09:00
Johannes Weiss 0e21dd7893 test that demonstrates overloading (#123)
Motivation:

SwiftLog is meant as a base logging library so users will often overload
certain functions with their own specialised and opinionated overloads.

Modification:

Add a test as demonstration.

Result:

More tests.
2020-03-17 14:35:48 -07:00
tomer doron 4d7ef13e01 additional doc generation fixes (#122)
motivation: better doc generation

changes:
* dont remove older docs when pushing new ones
* add version inforamtion and source links
2020-02-28 12:21:07 -08:00
tomer doron 4aad45c1c1 update docs generation script to work better with selinux (#121)
motivation: docs scripts is broken on selinux due to restriction on ssh-agent

changes: change the jazzy worksapce to a directory accessible by the CI node so we can push from the agent instead of from the docker container
2020-02-27 12:58:29 -08:00
Saleem AbdulrasoolandJohannes Weiss 1b5f8a5034 Logging: port to Windows (#118)
This adjusts the APIs to enable building swift-log on Windows.

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-02-26 17:08:18 +00:00
Saleem Abdulrasool 01ce2959de gitignore: ignore vim swapfiles (#119) 2020-02-26 14:30:38 +09:00
Ravi Kandhadai 57d2a6d872 Update README to clarify the drawbacks of using os_log through swift-log (#117)
The README file links to an implementation of a backend that uses os_log.
However, the backend always uses `%{public}@` as the format string and
eagerly converts all string interpolations to Strings.  This has two drawbacks:
1. the static components of the string interpolation would be eagerly copied by
the unified logging system, which will result in loss of performance.
2. It also changes the default privacy scheme used by os_log and make all message
private, which runs the risk of no message getting logged. Update the
README to capture this drawback. Also, link to the on-going effort on
improving os_log Swift APIs and aligning it with swift-log.
2020-02-24 19:33:16 +00:00
Will Lisac 7b01660491 Add wlisac/swift-log-slack to logging backend list (#115)
LoggingSlack is a logging backend for SwiftLog that sends log messages to Slack.
2020-02-16 23:46:17 -08:00
Artur Dryomov 27da3424c7 Add more syntax highlighting to the readme file (#114) 2020-02-06 11:02:57 +09:00
Franz Busch 3a9a783347 Fix small typo in tests (#113)
* Update LoggingTest.swift

* Apply suggestions from code review
2020-02-03 22:09:34 +09:00
tomer doron b321ca1807 improve docker security (#111)
motivation: more secured ci setup

changes:
* enable :z selinux flag on bind mounts so we can enable selinux on ci
* drop potentially exploitable capabilities from docker-compose
2020-01-29 08:36:34 +00:00
prafsoni 068014614c [feat] StreamLogHandler now adds label to log output (#108)
* [feat] StreamLogHandler now adds label to log output
* [test] add test cases for log out format assertion.
2019-12-18 01:38:07 -08:00
Neal Lester 012cff81f6 Reformatted backend implementation list as a table. Added swift-log-testing to the backend implementation (new) table. https://github.com/apple/swift-log/issues/105 (#106) 2019-11-21 14:35:36 -08:00
tomer doron f0f77b00c4 check for api breakage in ci and prepare to test with thread sanitizer (#102)
motivation: better ci testing

changes:
* add api breakage script to test api breakage in ci
* add "shell" utility docker-compose task to run api breakage script
* change test task to treat warning as errors
* prepare to test with thread sanitizer in 5.1
2019-11-04 16:42:41 -08:00
Thomas Krajacic 74d7b91cee Add .swiftpm to gitignore (#100) 2019-10-11 14:58:34 -07:00
Julian Kahnert 77b2e836f1 make Logger.Level codable (#99) 2019-09-26 17:47:27 +01:00
tomer doron 1111d309a5 swift 5.1 docker setup (#97)
motivation: support swift 5.1

changes:
* add docker compose file for swift 5.1, will add CI job once merged
* update swiftformat version to 0.40.12
* fix warning in tests
2019-09-23 22:39:36 -07:00
Tanner e5a4bd1003 add vapor/console-kit backend to README (#95) 2019-09-06 08:31:41 +01:00
Jordane Belanger fd6c6b338d Add StackdriverLogging to README (#93) #92
* Add StackdriverLogging to README

* Switch the  description in the README from using 'logger' to the 'logging backend' terminology
2019-08-27 08:16:48 +09:00
Nate Sanchez-Goodwin 6669bdf615 Remove level parameter from log helpers (#91) 2019-08-21 16:21:31 +01:00
tomer doron 6171b4483e update conduct email group (#90)
motivation: use consistent email across swift server projects 

changes: set conduct email address to swift-server-conduct@group.apple.com
2019-08-20 20:58:57 +01:00
Chris Aljoudi 2b7d68a486 Add swift-log-oslog logging backend link (#89) 2019-08-20 13:45:42 +01:00
Ian Partridge e8aabbe95d Add HeliumLogger to README (#88) 2019-08-16 17:13:06 +01:00
tomer doron e309184b89 add flush api to default stdout/stderr logger (#87)
* add flush api to default stdout/stderr logger

motivation: default logger may not flush the streams on crush, so need to make flushing moe explicit

changes:
* add a constructor argument to control flushing behaviour, default to "everytime"
* add a "flush" method to allow user defined flush timing. this api is now internal but we could expose it if there is a need
* add tests

* fixup
2019-08-13 10:59:48 +01:00
Johannes Weiss ebdfdcf0ff better documentation around MetadataValue being expressible by literals (#85)
* better documentation around MetadataValue being expressible by literals

Motivation:

In many examples, I could see that users seem to construct metadata
values using the explicit enum cases `.string("foo")`, `.array(...)`, as
well as `.dictionary(...)`. It's much more readable and easier to type
to just use `"foo"`, `["bar", "buz"]`, and `["qux": "quux"]` and rely on
the `ExpressibleBy...Literal` conformances.

Modifications:

Add the docs and examples.

Result:

Hopefully, users will read the docs and write more idiomatic code.

* Update Logging.swift
2019-08-07 11:43:28 +09:00
tomer doron 263735081c test formatting issues as part of sanity check (#84)
motivaiton: unified format

changes:
* use official docker image 🎉
* fix outstanding formatting issues
* add a call to swiftformat as part of sanity script
* fix sanity script language check debugging statements
2019-07-30 13:34:00 -07:00
Ian G 99786c85ac Add Adorkable/swift-log-format-and-pipe to Backend list (#83)
LoggingFormatAndPipe provides a Swift Logging API Handler which allows you to customized both your log messages' formats as well as their destinations.
2019-07-30 08:27:00 +01:00
Kevin Sweeney b33865f66b Fix documented ordering of Level (#78)
Levels are actually ordered from least severe to most severe, and their raw values are not exposed.
2019-06-25 22:52:56 +01:00
Konrad `ktoso` Malawski 9fc3834d3f Link to ianpartridge/swift-log-syslog backend impl (#73)
motivation: @ianpartridge implemented a backend for syslog (awesome :-)) so we should link to it so people are easily able to discover it (and any other future implementations we'd want to link to).
2019-06-24 19:55:56 -07:00
Max Desiatov df4d2c80df Fix typo in LogHandler doc comment (#76) 2019-06-03 10:01:42 -07:00
Max Desiatov f4240bf022 Add internal section link to README.md (#71) 2019-05-05 20:34:31 -07:00
Allen Humphreys ea3eea9dcb Expose an API for configuring basic stdio log handling (#61)
Expose `StreamLogHandler` to the public which replaces the previously internal `StdoutLogHandlers`. Users can choose now the output stream, while `stdout` is the default.

### Motivation:

As discussed on #51 and #60

### Modifications:

Rename `StdoutLogHandler` to `StreamLogHandler` and provide 2 factory methods `standardOutput(label:)` and `standardError(label:)` for using during bootstrapping.

### Result:

Users who adopt other logging backends during `LoggingSystem` bootstrapping will still be able to use the default log handler to get very basic console output to their choice of `stdout` or `stderr`.

### Example:
```
// Log to both stderr and stdout for good measure
LoggingSystem.bootstrap { 
    MultiplexLogHandler([
        FancyLoggingBackend(label: $0),
        StreamLogHandler.standardError(label: $0), 
        StreamLogHandler.standardOutput(label: $0)
    ])
}
```
2019-05-01 16:44:16 +01:00
Johannes Weiss 67b2425b4c add a CocoaPods podspec generator (#54)
Motivation:

Users ask for a CocoaPod. Unfortunately, the CocodPod `SwiftLog` is
already taken, so I went for `SwiftLogAPI`.

Modification:

Add a podspec generator.

Result:

Happier users.
2019-04-30 16:32:19 +01:00
Johannes Weiss dbb9d24d8d Update README.md 2019-04-26 09:03:08 +01:00
Johannes Weiss 3e8f2138a1 explain the upcoming SwiftLog 0 (#69) 2019-04-25 19:29:27 +01:00
tsuyoshi hyuga a26395d403 changed to isEmpty. (#65) 2019-04-25 10:48:14 +01:00
Ian Partridge 0c403de592 docs: improve API documentation coverage (#67) 2019-04-25 10:47:00 +01:00
Yim Lee 9ac2ad4064 Fix API documentation (#66)
Motivation:

API doc contains misinformation.

Modifications:

Update documentation for `Logger` API to match code.

Result:

API doc is correct.
2019-04-24 22:14:10 +01:00
tomer doron 75c08c0611 Add 'Show on GitHub' link to API docs (#64)
Motivation:

Allowing readers of the API documentation to drill into the implementation of documented declarations can be educational and helpful for debugging, among several other reasons.

Modifications:

Add --github-file-prefix appending the current version in order to keep stable links. This means that documentation generated from any non-release revision may resolve incorrectly. This can be refined in the doc generation script later if it is deemed problematic by resolving to the commit sha if it doesn't exactly align with the version.

Result:

Users will be able to click a 'Show on GitHub' for all documented API declarations.
2019-04-23 12:16:48 -07:00
tomer doron cfd8740667 add git commit template (#62)
motivation: missing the template mentioned in the contribution guides

changes: add dev directory with the git commit template
2019-04-19 10:55:23 +01:00
grundoon 250cef01ad fix docs #file -> #function (#59)
* fix docs #file -> #function

Multiple occurrences of `#file` in docs where `#function` was intended.

* add missing parentheses to parameter docs
2019-04-17 08:59:41 +01:00
Daniel Höpfl 33ceed2816 Fixed typo. (#58) 2019-04-16 09:30:39 -07:00
tomer doron 6397eee678 add contribution guidelines and github default config (#55)
motivation: adopt contribution guidelines and github PR conventions

changes:
* add contributing guidelines, including commit message template
* add github PR guidelines, including PR message template
2019-04-15 11:11:04 -07:00
tomer doron 4fe877816a fix linux tests formatting (#45)
motivation: use consistent formatting

changes: update generate_linux_tests to match the formatting rules we use: `swiftformat --self insert --patternlet inline --stripunusedargs unnamed-only --comments ignore`
2019-04-15 17:29:30 +01:00
tomer doron 851eacf76e fix docker setup to use release version of swift 5 (#48)
motivation: swift 5 was already released, use the release version for CI

changes: remove the dev verion from docker compose setup
2019-04-15 17:28:03 +01:00
Konrad `ktoso` Malawski 856a83e9f4 Link to more appropriate (still open) Swift issue (#50)
The original issue that was https://bugs.swift.org/browse/SR-9687 has been closed as duplicate of https://bugs.swift.org/browse/SR-9686
Perhaps it would be less confusing for others reading the code if we linked to the not-closed issue?

Not a big deal, just something I noticed; if we want to continue to link to the original issue that's fine too.
2019-04-15 11:59:33 +01:00
Konrad `ktoso` Malawski e37f28a5ff Fix typo in "critical" words in docs (#49) 2019-04-15 11:19:09 +01:00
David Okun a4828d9184 Added CaseIterable to Logger.Level enum (#46)
* Added CaseIterable to Logger.Level enum
2019-04-12 14:49:25 +01:00
tomer doron 9a393a5d35 retain SwiftNIO copyright header (#44)
motivation: retain copyrights

changes:
* add notice file with references to derived work
* add swift-nio license header to lock
2019-04-11 14:12:41 +01:00
Johannes Weiss 3924b3b96e readme: fix log levels (#43) 2019-04-10 10:04:51 -07:00
tomer doron 23f0f6ee6e fix typo in API docs (#42)
motivation: better docs

changes: swidft-log -> SwiftLog in an API doc that got it wrong
2019-04-10 18:02:11 +01:00
tomer doron f6a420460d use consistent, swifty naming convention (#41)
motivation: prepare to release

changes: refer to package as SwiftLog across the board isntead of swift-log
2019-04-10 17:45:54 +01:00
Johannes Weiss a64dd7dafc update readme for 1.0.0 (#39) 2019-04-10 16:26:23 +01:00
Johannes Weiss ca922e38f5 remove Logger.metadata property (#36)
Motivation:

Logger had two ways to access the metadata:

    logger[metadataKey: "foo"] = "bar"

and

    logger.metadata["foo"] = "bar"

. The first one is the preferred API (as it doesn't force the
`LogHandler`s to store it in a dictionary) but the second one was still
available for cases where you need to import/export the whole metadata
storage.

Instead of exposing this as a dictionary, we should make the
'whole-metadata import/export' opaque. We're close to tagging 1.0.0
however let's design this API properly and add a sensible implementation
for 1.1.0 or so.

Moditications:

remove `Logger.metadata` property

Result:

- We can design the import/export APIs and add them when they're ready.
- the `LogHandler` API is unchanged
2019-04-08 20:28:10 +01:00
Johannes Weiss 09c2837476 change log levels to be more natural (#35)
Motivation:

The syslog log level was unnatural in order (`.error` < `.info`) but also
didn't have `.trace` and instead the odd `.emergency` and `.alert`.

Modification:

As per https://forums.swift.org/t/logging-levels-for-swifts-server-side-logging-apis-and-new-os-log-apis/20365/56 ,
we decided to go for

    trace < debug < info < notice < warning < error < critical

and also remove the integrals completely. The levels remain comparable
though.

Result:

log levels more natural
2019-04-05 18:42:39 +01:00
Joe Smith 55c927dd31 Add small tweaks to the README. (#30)
* Add small tweaks to the README.
2019-03-27 18:07:34 +00:00
tomer doron 17d1835dac improve doc generation script (#29)
motivation: script did not capture changes correctly

changes: use a temp directory to store state aside before swiftching to gh-page branch
2019-03-26 08:34:17 +00:00
tomer doron 643fdba31a fix linux tests (#28)
motivation: a PR with broken linux tests have been merged

changes: run ./scripts/generate_linux_tests
2019-03-25 17:43:58 -07:00
Abdullah Selek d81e7db5f7 Delete trailing whitespaces. (#26) 2019-03-22 13:37:16 +00:00
pakuchii 870e880fc4 Fix grammar in README (#24) 2019-03-22 09:15:20 +00:00
Seungyeon Lee e65117937a Fix README (#25)
- Update parameter type.
2019-03-22 09:14:46 +00:00
Braden Keith ef8cc5a5d5 Update Readme.md (#23)
Providing an update to the readme that fixes a redundant phrase and some comma splices/omissions.
2019-03-21 18:18:01 +00:00
Johannes Weiss b4dfce827c docs gen script: escape EOF correctly (#21) 2019-03-20 15:56:05 +00:00
Johannes Weiss e60caa9502 improve the LogHandler documentation (#17)
Motivation:

Correct `LogHandler` implementation is very imprortant for a working
swift-log ecosystem. Treating the `logLevel` as a value has lead to
confusion in the discussion leading to this project though.

Modification:

- add documentation on the implementation of a `LogHandler`
- move `LogHandler` to its own file
- add a unit test showcasing a global log level override

Result:

better docs
2019-03-20 15:24:34 +00:00
Kirill Titov 4c01a824b7 Formatting, readability (#15) 2019-03-19 12:24:17 +00:00
Abdullah Selek bee6142a07 Fix for spaces and new line end of file. (#16) 2019-03-19 11:49:20 +00:00
Johannes Weiss 399f98f61f fix docs overview (only one module) (#14) 2019-03-18 19:07:32 +00:00
Johannes Weiss c217b32d46 improve readme (#13) 2019-03-18 18:42:20 +00:00
Johannes Weiss f0a5088707 make MultiplexLogHandler a value (#12) 2019-03-18 18:05:52 +00:00
Johannes Weiss 766ff20cc8 explicitly mark functions on internal types as internal (for jazzy) (#11) 2019-03-18 17:41:13 +00:00
Johannes Weiss 98886523fb first cut at API docs (#8) 2019-03-15 18:26:22 +00:00
Kevin Sweeney 3eba0ff608 Fix typo in README example (#9) 2019-03-15 18:19:03 +00:00
Johannes Weiss 284bf1fdeb switch #file/#function to String (#4)
Motivation:

With the new, awesome Swift 5 `String`s, there doesn't seem to be any
point in using `StaticString`s anymore. `String` seems to use immortal
strings for literals now and is in fact 1 byte less wide than
StaticString.

Modification:

Switch all StaticString for String

Result:

better asm (slightly shorter), fewer registers burnt, more features
2019-03-14 11:32:08 +00:00
Johannes Weiss 1039ca5db2 StdoutHandler: add colon after log level (#5) 2019-03-14 11:31:56 +00:00
tomer doron 94caaf2910 docker setup and linux tests (#7)
motivation: prepare to release

changes:
* add docker setup
* fix tests to pass correctly on linux
* add sanity scripts to make sure linux tests are present
* add doc generation scripts
* fix few naming mistakes in collateral
2019-03-14 11:31:47 +00:00
Johannes Weiss 3f53e0ab50 README: first cut (#6) 2019-03-13 22:27:50 +00:00
Johannes Weiss 46735c242a Package.swift: rename to swift-log 2019-03-07 18:33:20 +00:00
Johannes Weiss 78b84e39ff address #2: provide an example logging a String (#3)
- fixes #2
2019-03-05 19:44:46 +00:00
Johannes Weiss 7dd7738627 allow string interpolations in log messages 2019-03-01 10:59:17 +00:00
Johannes Weiss 306f432f6c convert to struct Logger.Message from String 2019-02-26 11:19:58 +00:00
Johannes Weiss c693fb6db1 switch to syslog log levels 2019-02-26 09:57:44 +00:00
Johannes Weiss 6254844827 remove examples, add code of conduct, Swift 5 2019-02-26 09:06:55 +00:00
Johannes Weiss 7db09d7d68 add license information (#48) 2019-02-24 13:51:38 +00:00
tomer doron c7583429a6 enforce that logging system can only be bootstrapped once (#32)
motivation: safer logging system

changes: do a precondition check to verify logging syste is only initialized/bootstrapped once per process
2019-02-22 18:13:52 +00:00
tomer doron 045ba36718 remove error argument from logging API (#34)
motivation: since Error in swift does not carry any additional information (such as stack traces) that can be useful in formatting decision the LogHandler may need to do, there is no real reason to treat it as special in the API, and it can just be "strigified" at the calling site

changes: remove error params from all APIs
2019-02-22 18:02:14 +00:00
Thomas Krajacic 9bd90f06ba Add label to Logger (#50) 2019-02-22 14:43:11 +00:00
Johannes Weiss 45c6d10678 rename Logging to LoggingSystem (#49) 2019-02-22 13:38:22 +00:00
tomer doron aa3990dfa0 support custom logging factories (#33)
motivation: make the API flexible enough so that users that need to inject custom factories as an escape hatch can do that

changes: add a Logging::make API variant that takes a custom factory instead of the default one
2019-02-22 13:28:41 +00:00
Konrad `ktoso` Malawski b0e59933ac Allow carrying CustomStringConvertible in metadata #24 (#25)
This has numerous benefits, most of which center around values which may
have expensive to perform custom `description` implementations, e.g.
yet are neither a dictionary nor an array.

It also allows carrying and thus "delaying" rendering of string
representations until they are actually needed. E.g. one can imagine
wanting to avoid rendering a string representation of a value if a
logger never would log any of the metadata, esp. if the rendering is a
heavy process.
2019-02-19 12:17:42 +00:00
Thomas Krajacic 5c135cd948 Add O_APPEND to flags (#45) 2019-02-19 11:44:24 +00:00
Johannes Weiss 32e9fa5158 make log function public (#44) 2019-02-19 11:43:51 +00:00
Thomas Krajacic 1b17eac10e Add newline to String being written (#47) 2019-02-19 11:01:59 +00:00
Johannes Weiss 034334268a fix the build (#43) 2019-02-19 08:50:55 +00:00
David Hart 2474d61a80 Multiple proposal improvements to the API (#41)
* Move `Logging.make` to a `Logger` initializer.
* Remove all factory initializers in example and test code.
2019-02-18 20:27:59 +01:00
Tanner 03174f3260 string interpolation fix (#42) 2019-02-12 17:16:54 +01:00
Konrad `ktoso` Malawski ed51baef90 Align names of Multiplexing loggers #37 (#38) 2019-01-29 09:53:13 +00:00
Max Moiseev 91f6b1017c MultiplexLogging.make(label:) => make(_:) (#36) 2019-01-29 09:52:16 +00:00
Ian Partridge 66bd922254 Improve timestamp calculation (#35) 2019-01-21 15:41:33 +00:00
tomer doron 466a7ed384 fix compilation on 4.2 (#31)
motivation: recent change for 5.x broken 4.x

changes: add code branch for swift < 5
2019-01-17 21:38:53 +00:00
tomer doron 11ea26a505 improve global logging example (#30)
motivation: better example

changes: the exmaple is single threaded, but better to show how to properly use global loggers (although we discourage them)
2019-01-17 18:38:23 +00:00
tomer doron 1d983153b4 change example loggers to structs (#29)
motivation: encourage use of immutable loggers

changes: change example loggers to structs
2019-01-17 18:10:54 +00:00
Konrad `ktoso` Malawski 0bf0588b17 Avoids regression SR-9687 in Swift 5 by not applying extensions to type aliased type (#27) 2019-01-17 11:31:07 +00:00
Konrad `ktoso` Malawski d370d101be fix a few typos in comments (#28) 2019-01-17 11:07:19 +00:00
Iain Smith b96c0e2b61 Improve code highlighting on Github (#21) 2019-01-15 15:52:30 +00:00
Johannes Weiss ba9eac9055 fixed small errors/typos etc 2019-01-14 12:36:08 +00:00
Johannes Weiss 899b7cb9db updated proposal (#20) 2019-01-09 18:46:45 +00:00
Johannes Weiss dfffdaa429 remove Metadata.Value.lazy (#18)
Motivation:

Two reasons for the removal:

1. I don't see a compelling reason to add lazy metadata to the metadata
   storage. Lazy metadata makes sense if it's passed directly to a log
   method like

       logger.info("foo", metadata: somethingExpensive())

   but I don't think this makes a whole lot of sense

       logger[metadataKey: "foo"] = .lazy({ somethingExpensive() })

   why? It's very likely that it'll get evalutated because any next
   log message that gets logged will force it but it's totally
   unclear which one that'll be.

2. More importantly, the lazy metadata can't be implemented correctly
   because we can't memoize the result of the expensive computation
   because we can only mutate the `LogHandler` in mutating methods and
   the log methods aren't mutating.
2019-01-09 15:47:09 +00:00
tomer doron a0c3ceabdf add support for local metadata (#16)
motivation: allow users to define metadata at the log API call site

changes: add metadata param to all log APIs, and implement merge at our example implementations
2019-01-09 12:04:59 +00:00
tomer doron 5ca706eb48 make logger metadata non-optional (#15)
motivation: simpler / cleaner API

changes: change logger Metadata API to be non-nullable, since the original motivation is no longer valid
2019-01-08 21:11:12 +00:00
tomer doron 19d987b6d5 add logger API variants that take an error (#12)
motivation: easily log errors w/o converting them to string first

changes:
* add another set of logger APIs that take in an error object
* add tests and refactor testing assertions
* add autoclosure tests to make sure its resoved on when log level is appropriate
2019-01-08 20:41:03 +00:00
Johannes Weiss 5527732754 Merge pull request #11 from weissi/jw-nested
nest types & allow nested metadata
2019-01-08 18:26:40 +00:00
Johannes Weiss c7ac24db1f nest types & allow nested metadata 2019-01-08 18:13:52 +00:00
Johannes Weiss e658d61717 Merge pull request #13 from tomerd/refacor
cleanup swift package
2019-01-05 11:21:47 +00:00
Johannes Weiss 1f1965107f Merge pull request #14 from tomerd/refactor2
refactor examples and remove dependecy on foundation
2019-01-05 11:21:24 +00:00
tomer doron 9027df5f03 refactor examples and remove dependecy on foundation
motivation:
* due to the low level nature of the library we prefer not to force-load foundation
* help reviewers diffrentiate between examples of usage vs implementation, and add more realistic usage and implementations examples

changes:
* remove foundation from Logging module, replace with c based locks and time functions
* rewrite usage examples to be more realistic
* add example of an implementation that writes to files
* add example of an implementation that is config driven
* rename warn -> warning
2019-01-05 02:03:44 -08:00
tomer doron 207bedfa31 cleanup swift package
motivation: remove clutter

changes:
* remove default comments
* rename module
2019-01-04 16:23:47 -08:00
Johannes Weiss 0f23cda751 Merge pull request #10 from tomerd/master
add multiplex logger
2019-01-04 10:35:45 +00:00
tomer doron 132af4ff5a add multiplex logger
motivation: support situations when users want to multiplex to multiple logging implementations

changes:
* add MultiplexLogging (factory) and MUXLogHandler (implementation), allowing user to plug in multiple logging implementations
* add tests and examples to demonstrate the functionality
2019-01-02 14:58:37 -08:00
Johannes Weiss 3ff1b2d3f5 updates 2018-12-15 12:14:47 +00:00
Johannes Weiss 05379f3987 fix package.swift 2018-12-14 15:16:35 +00:00
Johannes Weiss 11df2dc68b proposal: first cut at the prose 2018-12-13 17:27:18 +00:00
Johannes Weiss ed535d4ec8 test value property in local logger 2018-12-12 17:53:04 +00:00
Johannes Weiss 50a8c8fdac use the term "metadata" 2018-12-12 17:43:59 +00:00
tomer doron c7c54cc237 update open issues list
motivation: reflect current open issues

changes: update readme to reflect current open issues
2018-12-11 18:04:51 -08:00
tomer doron b5dcb3140e naming proposal (#2)
* naming proposal

motivation: intuitive APIs

changes:
* Logger is the main API users interact with
* Logging is the factory from which users get instances of Logger, via Logging.for(identifer)
* LogHandler is what logging libraries implement, this is not exposed to users as its boxed in Logger
* replace Logging (aka LoggerFactory) factory property with bootstrap(factory) function
* rename main module to Logging since its not server only
* converge examples into an Examples module

open questions:
* Logging.make or Logging.for
* is Logging.for(object: Any.Type) a good idea? is there a better way to get the FQN for an object?
2018-12-10 15:11:03 -08:00
Johannes Weiss a4cb92d526 Merge pull request #1 from tomerd/master
logger metadata support and unit tests
2018-12-05 11:31:32 +00:00
tomer doron bf76e03ea3 logger metadata support and unit tests
motivation: add tests to confirm desired functionality

changes:
* add property for logger metadata (aka context)
* improve pretty-metadata (aka pretty-context) generation
* add unit tests covering local and global use cases
* add [test only] implementation of MDC
* format with swiftformat

open issues:
* should we name the new property metadata or context
* should we include a default MDC implmentation as part of the logging API. if we dont, we will encourage libraries binding to specific logging implementations that support it (that was bad in java)
* tests are a bit brittle
* why is ExampleLoggerImplementation a reference type?
2018-12-03 18:32:51 -08:00
Johannes Weiss d3fc8c10e4 minor readme tweak 2018-12-03 17:45:24 +00:00
Johannes Weiss edd354fa76 hide the existential 2018-12-03 17:43:55 +00:00
Johannes Weiss c5c893e7ff evaluate @autoclosure before passing to existential 2018-11-30 21:36:59 +00:00
Johannes Weiss d756065630 initial commit 2018-11-06 16:55:31 +00:00
147 changed files with 6506 additions and 29680 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+20
View File
@@ -0,0 +1,20 @@
### Expected behavior
_[what you expected to happen]_
### Actual behavior
_[what actually happened]_
### Steps to reproduce
1. ...
2. ...
### If possible, minimal yet complete reproducer code (or URL to code)
_[anything to help us reproducing the issue]_
### SwiftLog version/commit hash
_[the SwiftLog tag/commit hash]_
### Swift & OS version (output of `swift --version && uname -a`)
+13
View File
@@ -0,0 +1,13 @@
_[One line description of your change]_
### Motivation:
_[Explain here the context, and why you're making that change. What is the problem you're trying to solve.]_
### Modifications:
_[Describe the modifications you've done.]_
### Result:
_[After your change, what will change.]_
+14
View File
@@ -0,0 +1,14 @@
changelog:
categories:
- title: SemVer Major
labels:
- ⚠️ semver/major
- title: SemVer Minor
labels:
- 🆕 semver/minor
- title: SemVer Patch
labels:
- 🔨 semver/patch
- title: Other Changes
labels:
- semver/none
+43
View File
@@ -0,0 +1,43 @@
name: Main
on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"
jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
static-sdk:
name: Static SDK
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
macos-tests:
name: macOS tests
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
with:
runner_pool: nightly
build_scheme: swift-log
+47
View File
@@ -0,0 +1,47 @@
name: PR
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "Swift Logging API"
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
static-sdk:
name: Static SDK
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
macos-tests:
name: macOS tests
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
with:
runner_pool: general
build_scheme: swift-log
+18
View File
@@ -0,0 +1,18 @@
name: PR label
on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]
jobs:
semver-label-check:
name: Semantic version label check
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
+13
View File
@@ -0,0 +1,13 @@
.DS_Store
Package.resolved
/.build
/Packages
/*.xcodeproj
.xcode
DerivedData
.swiftpm
.SourceKitten/
docs/
.*.sw?
+42
View File
@@ -0,0 +1,42 @@
.gitignore
**/.gitignore
.licenseignore
.unacceptablelanguageignore
.gitattributes
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.editorconfig
.github/*
*.md
*.txt
*.yml
*.yaml
*.json
Package.swift
**/Package.swift
Package@-*.swift
**/Package@-*.swift
Package.resolved
**/Package.resolved
Makefile
*.modulemap
**/*.modulemap
**/*.docc/*
*.xcprivacy
**/*.xcprivacy
*.symlink
**/*.symlink
Dockerfile
**/Dockerfile
Snippets/*
dev/git.commit.template
dev/update-benchmark-thresholds
*.crt
**/*.crt
*.pem
**/*.pem
*.der
**/*.der
+6
View File
@@ -0,0 +1,6 @@
Tomer Doron <tomer@apple.com> <tomer.doron@gmail.com>
Tomer Doron <tomer@apple.com> tomer doron <tomer@apple.com>
Tomer Doron <tomer@apple.com> tomer doron <tomerd@apple.com>
Johannes Weiss <johannesweiss@apple.com> <johannes@jweiss.io>
Max Moiseev <moiseev@apple.com> <moiseev@users.noreply.github.com>
Konrad `ktoso` Malawski <ktoso@apple.com> <konrad.malawski@project13.pl>
View File
Whitespace-only changes.
+4
View File
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [Logging]
+62
View File
@@ -0,0 +1,62 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"tabWidth" : 4,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 120,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
+3
View File
@@ -0,0 +1,3 @@
# Code of Conduct
The code of conduct for this project can be found at https://swift.org/code-of-conduct.
+96
View File
@@ -0,0 +1,96 @@
## Legal
By submitting a pull request, you represent that you have the right to license
your contribution to Apple and the community, and agree by submitting the patch
that your contributions are licensed under the Apache 2.0 license (see
`LICENSE.txt`).
## How to submit a bug report
Please ensure to specify the following:
* SwiftLog commit hash
* Contextual information (e.g. what you were trying to achieve with SwiftLog)
* Simplest possible steps to reproduce
* More complex the steps are, lower the priority will be.
* A pull request with failing test case is preferred, but it's just fine to paste the test case into the issue description.
* Anything that might be relevant in your opinion, such as:
* Swift version or the output of `swift --version`
* OS version and the output of `uname -a`
* Network configuration
### Example
```
SwiftLog commit hash: 4fe877816ad82627602377f415b6a66850214824
Context:
While testing my application that uses with SwiftLog, I noticed that ...
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
$ swift --version
Swift version 4.0.2 (swift-4.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Operating system: Ubuntu Linux 16.04 64-bit
$ uname -a
Linux beefy.machine 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
My system has IPv6 disabled.
```
## Writing a Patch
A good SwiftLog patch is:
1. Concise, and contains as few changes as needed to achieve the end result.
2. Tested, ensuring that any tests provided failed before the patch and pass after it.
3. Documented, adding API documentation as needed to cover new functions and properties.
4. Accompanied by a great commit message, using our commit message template.
### Commit Message Template
We require that your commit messages match our template. The easiest way to do that is to get git to help you by explicitly using the template. To do that, `cd` to the root of our repository and run:
git config commit.template dev/git.commit.template
### Make sure Tests work on Linux
SwiftLog uses XCTest to run tests on both macOS and Linux. While the macOS version of XCTest is able to use the Objective-C runtime to discover tests at execution time, the Linux version is not.
For this reason, whenever you add new tests **you have to run a script** that generates the hooks needed to run those tests on Linux, or our CI will complain that the tests are not all present on Linux. To do this, merely execute `ruby ./scripts/generate_linux_tests.rb` at the root of the package and check the changes it made.
### Run `./scripts/soundness.sh`
The scripts directory contains a [soundness.sh script](https://github.com/apple/swift-log/blob/main/scripts/soundness.sh)
that enforces additional checks, like license headers and formatting style.
Please make sure to `./scripts/soundness.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail
on minor changes such as a missing `self.` or similar formatting issues.
> The script also executes the above mentioned `generate_linux_tests.rb`.
For frequent contributors, we recommend adding the script as a [git pre-push hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), which you can do via executing the following command in the project root directory:
```bash
cat << EOF > .git/hooks/pre-push
#!/bin/bash
if [[ -f "scripts/soundness.sh" ]]; then
scripts/soundness.sh
fi
EOF
```
Which makes the script execute, and only allow the `git push` to complete if the check has passed.
In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.
## How to contribute your work
Please open a pull request at https://github.com/apple/swift-log. Make sure the CI passes, and then wait for code review.
+27
View File
@@ -0,0 +1,27 @@
For the purpose of tracking copyright, this is the list of individuals and
organizations who have contributed source code to the Swift Logging API.
For employees of an organization/company where the copyright of work done
by employees of that company is held by the company itself, only the company
needs to be listed here.
## COPYRIGHT HOLDERS
- Apple Inc. (all contributors with '@apple.com')
### Contributors
- David Hart <david@hartbit.com>
- Iain Smith <iainsmith@users.noreply.github.com>
- Ian Partridge <i.partridge@uk.ibm.com>
- Johannes Weiss <johannesweiss@apple.com>
- Kevin Sweeney <kevin.t.sweeney@gmail.com>
- Konrad `ktoso` Malawski <ktoso@apple.com>
- Max Moiseev <moiseev@apple.com>
- Tanner <me@tanner.xyz>
- Thomas Krajacic <tkrajacic@users.noreply.github.com>
- Tomer Doron <tomer@apple.com>
**Updating this list**
Please do not edit this file manually. It is generated using `./scripts/generate_contributors_list.sh`. If a name is misspelled or appearing multiple times: add an entry in `./.mailmap`
+202
View File
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+44
View File
@@ -0,0 +1,44 @@
The SwiftLog Project
========================
Please visit the SwiftLog web site for more information:
* https://github.com/apple/swift-log
Copyright 2018, 2019 The SwiftLog Project
The SwiftLog Project licenses this file to you under the Apache License,
version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at:
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Also, please refer to each LICENSE.<component>.txt file, which is located in
the 'license' directory of the distribution file, for the license terms of the
components that this product depends on.
-------------------------------------------------------------------------------
This product contains a derivation of the Tony Stone's 'process_test_files.rb'.
* LICENSE (Apache License 2.0):
* https://www.apache.org/licenses/LICENSE-2.0
* HOMEPAGE:
* https://codegists.com/snippet/ruby/generate_xctest_linux_runnerrb_tonystone_ruby
---
This product contains a derivation of the lock implementation and various
scripts from SwiftNIO.
* LICENSE (Apache License 2.0):
* https://www.apache.org/licenses/LICENSE-2.0
* HOMEPAGE:
* https://github.com/apple/swift-nio
+55
View File
@@ -0,0 +1,55 @@
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import PackageDescription
let package = Package(
name: "swift-log",
products: [
.library(name: "Logging", targets: ["Logging"])
],
targets: [
.target(
name: "Logging",
dependencies: []
),
.testTarget(
name: "LoggingTests",
dependencies: ["Logging"]
),
]
)
for target in package.targets {
var settings = target.swiftSettings ?? []
settings.append(.enableExperimentalFeature("StrictConcurrency=complete"))
target.swiftSettings = settings
}
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
for target in package.targets {
switch target.type {
case .regular, .test, .executable:
var settings = target.swiftSettings ?? []
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
target.swiftSettings = settings
case .macro, .plugin, .system, .binary:
() // not applicable
@unknown default:
() // we don't know what to do here, do nothing
}
}
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
+64
View File
@@ -0,0 +1,64 @@
# SwiftLog
This repository contains a logging API implementation for Swift.
SwiftLog provides a unified, performant, and ergonomic logging API that can be
adopted by libraries and applications across the Swift ecosystem.
- 📚 **Documentation** and **tutorials** are available on the [Swift Package Index](https://swiftpackageindex.com/apple/swift-log)
- 🚀 **Contributions** are welcome, please see [CONTRIBUTING.md](CONTRIBUTING.md)
- 🪪 **License** is Apache 2.0, repeated in [LICENSE.txt](LICENSE.txt)
- 🔒 **Security** issues should be reported via the process in [SECURITY.md](SECURITY.md)
- 🔀 **Available Logging Backends**: SwiftLog is an API package - you'll want to
choose from the many
[community-maintained logging backends](#available-log-handler-backends) for production use
## Quick Start
The following snippet shows how to add SwiftLog to your Swift Package:
```swift
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "YourApp",
dependencies: [
.package(url: "https://github.com/apple/swift-log", from: "1.6.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "Logging", package: "swift-log")
]
)
]
)
```
Then start logging:
```swift
import Logging
// Create a logger
let logger = Logger(label: "com.example.YourApp")
// Log at different levels
logger.info("Application started")
logger.warning("This is a warning")
logger.error("Something went wrong", metadata: ["error": "\(error)"])
// Add metadata for context
var requestLogger = logger
requestLogger[metadataKey: "request-id"] = "\(UUID())"
requestLogger.info("Processing request")
```
## Available log handler backends
The community has built numerous specialized logging backends.
A great way to discover available log backend implementations is searching the
[Swift Package Index](https://swiftpackageindex.com/search?query=swift-log)
for the `swift-log` keyword.
+43
View File
@@ -0,0 +1,43 @@
# Security
This document specifies the security process for the SwiftLog project.
## Disclosures
### Private Disclosure Process
The SwiftLog maintainers ask that known and suspected vulnerabilities be
privately and responsibly disclosed by emailing
[sswg-security-reports@forums.swift.org](mailto:sswg-security-reports@forums.swift.org)
with the all the required detail.
**Do not file a public issue.**
#### When to report a vulnerability
* You think you have discovered a potential security vulnerability in SwiftLog.
* You are unsure how a vulnerability affects SwiftLog.
#### What happens next?
* A member of the team will acknowledge receipt of the report within 3
working days (United States). This may include a request for additional
information about reproducing the vulnerability.
* We will privately inform the Swift Server Work Group ([SSWG][sswg]) of the
vulnerability within 10 days of the report as per their [security
guidelines][sswg-security].
* Once we have identified a fix we may ask you to validate it. We aim to do this
within 30 days. In some cases this may not be possible, for example when the
vulnerability exists at the protocol level and the industry must coordinate on
the disclosure process.
* If a CVE number is required, one will be requested from [MITRE][mitre]
providing you with full credit for the discovery.
* We will decide on a planned release date and let you know when it is.
* Prior to release, we will inform major dependents that a security-related
patch is impending.
* Once the fix has been released we will publish a security advisory on GitHub
and in the Server → Security Updates category on the [Swift forums][swift-forums-sec].
[sswg]: https://github.com/swift-server/sswg
[sswg-security]: https://www.swift.org/sswg/security/
[swift-forums-sec]: https://forums.swift.org/c/server/security-updates/
[mitre]: https://cveform.mitre.org/
@@ -0,0 +1,138 @@
# 001: Choosing log levels
Best practice for selecting appropriate log levels in applications and
libraries.
## Overview
SwiftLog defines seven log levels, and choosing the right level is crucial for
creating well-behaved libraries that don't overwhelm logging systems or misuse
severity levels. This practice provides clear guidance on when to use each
level.
### Motivation
Libraries must be well-behaved across various use cases and cannot assume
specific logging backend configurations. Using inappropriate log levels can
flood production logs, trigger false alerts, or make debugging more difficult.
Following consistent log level guidelines ensures your library integrates well
with diverse application environments.
### Log levels
SwiftLog defines seven log levels via ``Logger/Level``, ordered from least to
most severe:
- ``Logger/Level/trace``
- ``Logger/Level/debug``
- ``Logger/Level/info``
- ``Logger/Level/notice``
- ``Logger/Level/warning``
- ``Logger/Level/error``
- ``Logger/Level/critical``
### Level guidelines
How you use log levels depends in large part if you are developing a library, or
an application which bootstraps its logging system and is in full control over
its logging environment.
#### For libraries
Libraries should use **info level or lower** (info, debug, trace). Each level
serves different purposes:
Libraries **should not** log information on **warning or more severe levels**,
unless it is a one-time (for example during startup) warning, that cannot lead
to overwhelming log outputs.
##### Trace Level
- **Usage**: Log everything needed to diagnose hard-to-reproduce bugs
- **Performance**: May impact performance; assume it won't be used in production
- **Content**: Internal state, detailed operation flows, diagnostic information
##### Debug Level
- **Usage**: May be enabled in some production deployments
- **Performance**: Should not significantly undermine production performance
- **Content**: High-level operation overview, connection events, major decisions
##### Info Level
- **Usage**: Reserved for things that went wrong but can't be communicated
through other means like throwing from a method
- **Examples**: Connection retry attempts, fallback mechanisms, recoverable
failures
- **Guideline**: Use sparingly - not for normal successful operations
#### For applications
Applications can use **any level** depending on the context and what they want
to achieve. Applications have full control over their logging strategy.
#### Configuring logger log levels
It depends on the use-case of your application which log level your logger
should use. For **console and other end-user-visible displays**: Consider using
**notice level** as the minimum visible level to avoid overwhelming users with
technical details.
### Example
#### Recommended: Libraries should use info level or lower
```swift
// ✅ Good: Trace level for detailed diagnostics
logger.trace("Connection pool state", metadata: [
"active": "\(activeConnections)",
"idle": "\(idleConnections)",
"pending": "\(pendingRequests)"
])
// ✅ Good: Debug level for high-value operational info
logger.debug("Database connection established", metadata: [
"host": "\(host)",
"database": "\(database)",
"connectionTime": "\(duration)"
])
// ✅ Good: Info level for issues that can't be communicated through other means
logger.info("Connection failed, retrying", metadata: [
"attempt": "\(attemptNumber)",
"maxRetries": "\(maxRetries)",
"host": "\(host)"
])
```
#### Use sparingly: Warning and error levels
```swift
// ✅ Good: One-time startup warning or error
logger.warning("Deprecated TLS version detected. Consider upgrading to TLS 1.3")
```
#### Avoid: Logging potentially intentional failures at info level
Some failures may be completely intentional from the high-level perspective of a
developer or system using your library. For example: failure to resolve a
domain, failure to make a request, or failure to complete some task;
Instead, log at debug or trace levels and offer alternative ways to observe
these behaviors, for example using `swift-metrics` to emit counts.
```swift
// ❌ Bad: Normal operations at info level flood production logs
logger.info("Request failed")
```
#### Avoid: Normal operations at info level
```swift
// ❌ Bad: Normal operations at info level flood production logs
logger.info("HTTP request received")
logger.info("Database query executed")
logger.info("Response sent")
// ✅ Good: Use appropriate levels instead
logger.debug("Processing request", metadata: ["path": "\(path)"])
logger.trace("Query", , metadata: ["path": "\(query)"])
logger.debug("Request completed", metadata: ["status": "\(status)"])
```
@@ -0,0 +1,213 @@
# Implementing a log handler
Create a custom logging backend that provides logging services for your apps
and libraries.
## Overview
To become a compatible logging backend that any `SwiftLog` consumer can use,
you need to fulfill a few requirements, primarily conforming to the
``LogHandler`` protocol.
### Implement with value type semantics
Your log handler **must be a `struct`** and exhibit value semantics. This
ensures that changes to one logger don't affect others.
To verify that your handler reflects value semantics ensure that it passes this
test:
```swift
@Test
func logHandlerValueSemantics() {
LoggingSystem.bootstrap(MyLogHandler.init)
var logger1 = Logger(label: "first logger")
logger1.logLevel = .debug
logger1[metadataKey: "only-on"] = "first"
var logger2 = logger1
logger2.logLevel = .error // Must not affect logger1
logger2[metadataKey: "only-on"] = "second" // Must not affect logger1
// These expectations must pass
#expect(logger1.logLevel == .debug)
#expect(logger2.logLevel == .error)
#expect(logger1[metadataKey: "only-on"] == "first")
#expect(logger2[metadataKey: "only-on"] == "second")
}
```
> Note: In special cases, it is acceptable for a log handler to provide
> global log level overrides that may affect all log handlers created.
### Example implementation
Here's a complete example of a simple print-based log handler:
```swift
import Foundation
import Logging
public struct PrintLogHandler: LogHandler {
private let label: String
public var logLevel: Logger.Level = .info
public var metadata: Logger.Metadata = [:]
public init(label: String) {
self.label = label
}
public func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
let timestamp = ISO8601DateFormatter().string(from: Date())
let levelString = level.rawValue.uppercased()
// Merge handler metadata with message metadata
let combinedMetadata = Self.prepareMetadata(
base: self.metadata
explicit: metadata
)
// Format metadata
let metadataString = combinedMetadata.map { "\($0.key)=\($0.value)" }.joined(separator: ",")
// Create log line and print to console
let logLine = "\(label) \(timestamp) \(levelString) [\(metadataString)]: \(message)"
print(logLine)
}
public subscript(metadataKey key: String) -> Logger.Metadata.Value? {
get {
return self.metadata[key]
}
set {
self.metadata[key] = newValue
}
}
static func prepareMetadata(
base: Logger.Metadata,
explicit: Logger.Metadata?
) -> Logger.Metadata? {
var metadata = base
guard let explicit else {
// all per-log-statement values are empty
return metadata
}
metadata.merge(explicit, uniquingKeysWith: { _, explicit in explicit })
return metadata
}
}
```
### Advanced features
#### Metadata providers
Metadata providers allow you to dynamically add contextual information to all
log messages without explicitly passing it each time. Common use cases include
request IDs, user sessions, or trace contexts that should be included in logs
throughout a request's lifecycle.
```swift
import Foundation
import Logging
public struct PrintLogHandler: LogHandler {
private let label: String
public var logLevel: Logger.Level = .info
public var metadata: Logger.Metadata = [:]
public var metadataProvider: Logger.MetadataProvider?
public init(label: String) {
self.label = label
}
public func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
let timestamp = ISO8601DateFormatter().string(from: Date())
let levelString = level.rawValue.uppercased()
// Get provider metadata
let providerMetadata = metadataProvider?.get() ?? [:]
// Merge handler metadata with message metadata
let combinedMetadata = Self.prepareMetadata(
base: self.metadata,
provider: self.metadataProvider,
explicit: metadata
)
// Format metadata
let metadataString = combinedMetadata.map { "\($0.key)=\($0.value)" }.joined(separator: ",")
// Create log line and print to console
let logLine = "\(label) \(timestamp) \(levelString) [\(metadataString)]: \(message)"
print(logLine)
}
public subscript(metadataKey key: String) -> Logger.Metadata.Value? {
get {
return self.metadata[key]
}
set {
self.metadata[key] = newValue
}
}
static func prepareMetadata(
base: Logger.Metadata,
provider: Logger.MetadataProvider?,
explicit: Logger.Metadata?
) -> Logger.Metadata? {
var metadata = base
let provided = provider?.get() ?? [:]
guard !provided.isEmpty || !((explicit ?? [:]).isEmpty) else {
// all per-log-statement values are empty
return metadata
}
if !provided.isEmpty {
metadata.merge(provided, uniquingKeysWith: { _, provided in provided })
}
if let explicit = explicit, !explicit.isEmpty {
metadata.merge(explicit, uniquingKeysWith: { _, explicit in explicit })
}
return metadata
}
}
```
### Performance considerations
1. **Avoid blocking**: Don't block the calling thread for I/O operations.
2. **Lazy evaluation**: Remember that messages and metadata are autoclosures.
3. **Memory efficiency**: Don't hold onto large amounts of messages.
## See Also
- ``LogHandler``
- ``StreamLogHandler``
- ``MultiplexLogHandler``
@@ -0,0 +1,41 @@
# Logging best practices
Best practices for effective logging with SwiftLog.
## Overview
This collection of best practices helps library authors and application
developers create effective, maintainable logging that works well across diverse
environments. Each practice is designed to ensure your logs are useful for
debugging while being respectful of system resources and operational
requirements.
### Who Should Use These Practices
- **Library Authors**: Creating reusable components that log appropriately.
- **Application Developers**: Implementing logging strategies in applications.
### Philosophy
Good logging strikes a balance between providing useful information and avoiding
system overhead. These practices are based on real-world experience with
production systems and emphasize:
- **Predictable behavior** across different environments.
- **Performance consciousness** to avoid impacting application speed.
- **Operational awareness** to support production debugging and monitoring.
- **Developer experience** to make debugging efficient and pleasant.
### Contributing to these practices
These best practices evolve based on community experience and are maintained by
the Swift Server Working Group ([SSWG](https://www.swift.org/sswg/)). Each
practice includes:
- **Clear motivation** explaining why the practice matters
- **Concrete examples** showing good and bad patterns
- **Alternatives considered** documenting trade-offs and rejected approaches
## Topics
- <doc:001-ChoosingLogLevels>
+166
View File
@@ -0,0 +1,166 @@
# ``Logging``
A unified, performant, and ergonomic logging API for Swift.
## Overview
SwiftLog provides a logging API package designed to establish a common API the
ecosystem can use. It allows packages to emit log messages without tying them to
any specific logging implementation, while applications can choose any
compatible logging backend.
SwiftLog is an _API package_ which cuts the logging problem in half:
1. A logging API (this package)
2. Logging backend implementations (community-provided)
This separation allows libraries to adopt the API while applications choose any
compatible logging backend implementation without requiring changes from
libraries.
## Getting Started
Use this If you are writing a cross-platform application (for example, Linux and
macOS) or library, target this logging API.
### Adding the Dependency
Add the dependency to your `Package.swift`:
```swift
.package(url: "https://github.com/apple/swift-log", from: "1.6.0")
```
And to your target:
```swift
.target(
name: "YourTarget",
dependencies: [
.product(name: "Logging", package: "swift-log")
]
)
```
### Basic Usage
```swift
// Import the logging API
import Logging
// Create a logger with a label
let logger = Logger(label: "MyLogger")
// Use it to log messages
logger.info("Hello World!")
```
This outputs:
```
2019-03-13T15:46:38+0000 info: Hello World!
```
### Default Behavior
SwiftLog provides basic console logging via ``StreamLogHandler``. By default it
uses `stdout`, however, you can configure it to use `stderr` instead:
```swift
LoggingSystem.bootstrap(StreamLogHandler.standardError)
```
``StreamLogHandler`` is primarily for convenience. For production applications,
implement the ``LogHandler`` protocol directly or use a community-maintained
backend.
## Core Concepts
### Loggers
Loggers are used to emit log messages at different severity levels:
```swift
// Informational message
logger.info("Processing request")
// Something went wrong
logger.error("Houston, we have a problem")
```
``Logger`` is a value type with value semantics, meaning that when you modify a
logger's configuration (like its log level or metadata), it only affects that
specific logger instance:
```swift
let baseLogger = Logger(label: "MyApp")
// Create a new logger with different configuration.
var requestLogger = baseLogger
requestLogger.logLevel = .debug
requestLogger[metadataKey: "request-id"] = "\(UUID())"
// baseLogger is unchanged. It still has default log level and no metadata
// requestLogger has debug level and request-id metadata.
```
This value type behavior makes loggers safe to pass between functions and modify
without unexpected side effects.
### Log Levels
SwiftLog supports seven log levels (from least to most severe):
- ``Logger/Level/trace``
- ``Logger/Level/debug``
- ``Logger/Level/info``
- ``Logger/Level/notice``
- ``Logger/Level/warning``
- ``Logger/Level/error``
- ``Logger/Level/critical``
Log levels can be changed per logger without affecting others:
```swift
var logger = Logger(label: "MyLogger")
logger.logLevel = .debug
```
### Logging Metadata
Metadata provides contextual information crucial for debugging:
```swift
var logger = Logger(label: "com.example.server")
logger[metadataKey: "request-uuid"] = "\(UUID())"
logger.info("Processing request")
```
Output:
```
2019-03-13T18:30:02+0000 info: request-uuid=F8633013-3DD8-481C-9256-B296E43443ED Processing request
```
### Source vs Label
A ``Logger`` has an immutable `label` identifying its creator, while each log
message carries a `source` parameter identifying where the message originated.
Use `source` for filtering messages from specific subsystems.
## Topics
### Logging API
- ``Logger``
- ``LoggingSystem``
### Log Handlers
- ``LogHandler``
- ``MultiplexLogHandler``
- ``StreamLogHandler``
- ``SwiftLogNoOpLogHandler``
### Best Practices
- <doc:LoggingBestPractices>
- <doc:001-ChoosingLogLevels>
+289
View File
@@ -0,0 +1,289 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if canImport(WASILibc)
// No locking on WASILibc
#elseif canImport(Darwin)
import Darwin
#elseif os(Windows)
import WinSDK
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Android)
import Android
#elseif canImport(Musl)
import Musl
#else
#error("Unsupported runtime")
#endif
/// A threading lock based on `libpthread` instead of `libdispatch`.
///
/// This object provides a lock on top of a single `pthread_mutex_t`. This kind
/// of lock is safe to use with `libpthread`-based threading models, such as the
/// one used by NIO. On Windows, the lock is based on the substantially similar
/// `SRWLOCK` type.
internal final class Lock: @unchecked Sendable {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
fileprivate let mutex: UnsafeMutablePointer<SRWLOCK> =
UnsafeMutablePointer.allocate(capacity: 1)
#else
fileprivate let mutex: UnsafeMutablePointer<pthread_mutex_t> =
UnsafeMutablePointer.allocate(capacity: 1)
#endif
/// Create a new lock.
public init() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
InitializeSRWLock(self.mutex)
#else
var attr = pthread_mutexattr_t()
pthread_mutexattr_init(&attr)
pthread_mutexattr_settype(&attr, .init(PTHREAD_MUTEX_ERRORCHECK))
let err = pthread_mutex_init(self.mutex, &attr)
precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)")
#endif
}
deinit {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
// SRWLOCK does not need to be free'd
self.mutex.deallocate()
#else
let err = pthread_mutex_destroy(self.mutex)
precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)")
self.mutex.deallocate()
#endif
}
/// Acquire the lock.
///
/// Whenever possible, consider using `withLock` instead of this method and
/// `unlock`, to simplify lock handling.
public func lock() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
AcquireSRWLockExclusive(self.mutex)
#else
let err = pthread_mutex_lock(self.mutex)
precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)")
#endif
}
/// Release the lock.
///
/// Whenever possible, consider using `withLock` instead of this method and
/// `lock`, to simplify lock handling.
public func unlock() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
ReleaseSRWLockExclusive(self.mutex)
#else
let err = pthread_mutex_unlock(self.mutex)
precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)")
#endif
}
}
extension Lock {
/// Acquire the lock for the duration of the given block.
///
/// This convenience method should be preferred to `lock` and `unlock` in
/// most situations, as it ensures that the lock will be released regardless
/// of how `body` exits.
///
/// - Parameter body: The block to execute while holding the lock.
/// - Returns: The value returned by the block.
@inlinable
internal func withLock<T>(_ body: () throws -> T) rethrows -> T {
self.lock()
defer {
self.unlock()
}
return try body()
}
// specialise Void return (for performance)
@inlinable
internal func withLockVoid(_ body: () throws -> Void) rethrows {
try self.withLock(body)
}
}
/// A reader/writer threading lock based on `libpthread` instead of `libdispatch`.
///
/// This object provides a lock on top of a single `pthread_rwlock_t`. This kind
/// of lock is safe to use with `libpthread`-based threading models, such as the
/// one used by NIO. On Windows, the lock is based on the substantially similar
/// `SRWLOCK` type.
internal final class ReadWriteLock: @unchecked Sendable {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
fileprivate let rwlock: UnsafeMutablePointer<SRWLOCK> =
UnsafeMutablePointer.allocate(capacity: 1)
fileprivate var shared: Bool = true
#else
fileprivate let rwlock: UnsafeMutablePointer<pthread_rwlock_t> =
UnsafeMutablePointer.allocate(capacity: 1)
#endif
/// Create a new lock.
public init() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
InitializeSRWLock(self.rwlock)
#else
let err = pthread_rwlock_init(self.rwlock, nil)
precondition(err == 0, "\(#function) failed in pthread_rwlock with error \(err)")
#endif
}
deinit {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
// SRWLOCK does not need to be free'd
self.rwlock.deallocate()
#else
let err = pthread_rwlock_destroy(self.rwlock)
precondition(err == 0, "\(#function) failed in pthread_rwlock with error \(err)")
self.rwlock.deallocate()
#endif
}
/// Acquire a reader lock.
///
/// Whenever possible, consider using `withReaderLock` instead of this
/// method and `unlock`, to simplify lock handling.
fileprivate func lockRead() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
AcquireSRWLockShared(self.rwlock)
self.shared = true
#else
let err = pthread_rwlock_rdlock(self.rwlock)
precondition(err == 0, "\(#function) failed in pthread_rwlock with error \(err)")
#endif
}
/// Acquire a writer lock.
///
/// Whenever possible, consider using `withWriterLock` instead of this
/// method and `unlock`, to simplify lock handling.
fileprivate func lockWrite() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
AcquireSRWLockExclusive(self.rwlock)
self.shared = false
#else
let err = pthread_rwlock_wrlock(self.rwlock)
precondition(err == 0, "\(#function) failed in pthread_rwlock with error \(err)")
#endif
}
/// Release the lock.
///
/// Whenever possible, consider using `withReaderLock` and `withWriterLock`
/// instead of this method and `lockRead` and `lockWrite`, to simplify lock
/// handling.
fileprivate func unlock() {
#if canImport(WASILibc)
// WASILibc is single threaded, provides no locks
#elseif os(Windows)
if self.shared {
ReleaseSRWLockShared(self.rwlock)
} else {
ReleaseSRWLockExclusive(self.rwlock)
}
#else
let err = pthread_rwlock_unlock(self.rwlock)
precondition(err == 0, "\(#function) failed in pthread_rwlock with error \(err)")
#endif
}
}
extension ReadWriteLock {
/// Acquire the reader lock for the duration of the given block.
///
/// This convenience method should be preferred to `lockRead` and `unlock`
/// in most situations, as it ensures that the lock will be released
/// regardless of how `body` exits.
///
/// - Parameter body: The block to execute while holding the reader lock.
/// - Returns: The value returned by the block.
@inlinable
internal func withReaderLock<T>(_ body: () throws -> T) rethrows -> T {
self.lockRead()
defer {
self.unlock()
}
return try body()
}
/// Acquire the writer lock for the duration of the given block.
///
/// This convenience method should be preferred to `lockWrite` and `unlock`
/// in most situations, as it ensures that the lock will be released
/// regardless of how `body` exits.
///
/// - Parameter body: The block to execute while holding the writer lock.
/// - Returns: The value returned by the block.
@inlinable
internal func withWriterLock<T>(_ body: () throws -> T) rethrows -> T {
self.lockWrite()
defer {
self.unlock()
}
return try body()
}
// specialise Void return (for performance)
@inlinable
internal func withReaderLockVoid(_ body: () throws -> Void) rethrows {
try self.withReaderLock(body)
}
// specialise Void return (for performance)
@inlinable
internal func withWriterLockVoid(_ body: () throws -> Void) rethrows {
try self.withWriterLock(body)
}
}
+248
View File
@@ -0,0 +1,248 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// A `LogHandler` is an implementation of a logging backend.
///
/// This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
/// To use the SwiftLog API, please refer to the documentation of ``Logger``.
///
/// # Implementation requirements
///
/// To implement your own `LogHandler` you should respect a few requirements that are necessary so applications work
/// as expected regardless of the selected `LogHandler` implementation.
///
/// - The ``LogHandler`` must be a `struct`.
/// - The metadata and `logLevel` properties must be implemented so that setting them on a `Logger` does not affect
/// other `Logger`s.
///
/// ### Treat log level & metadata as values
///
/// When developing your `LogHandler`, please make sure the following test works.
///
/// ```swift
/// @Test
/// func logHandlerValueSemantics() {
/// LoggingSystem.bootstrap(MyLogHandler.init)
/// var logger1 = Logger(label: "first logger")
/// logger1.logLevel = .debug
/// logger1[metadataKey: "only-on"] = "first"
///
/// var logger2 = logger1
/// logger2.logLevel = .error // Must not affect logger1
/// logger2[metadataKey: "only-on"] = "second" // Must not affect logger1
///
/// // These expectations must pass
/// #expect(logger1.logLevel == .debug)
/// #expect(logger2.logLevel == .error)
/// #expect(logger1[metadataKey: "only-on"] == "first")
/// #expect(logger2[metadataKey: "only-on"] == "second")
/// }
/// ```
///
/// ### Special cases
///
/// In certain special cases, the log level behaving like a value on `Logger` might not be what you want. For example,
/// you might want to set the log level across _all_ `Logger`s to `.debug` when say a signal (eg. `SIGUSR1`) is received
/// to be able to debug special failures in production. This special case is acceptable but we urge you to create a
/// solution specific to your `LogHandler` implementation to achieve that. Please find an example implementation of this
/// behavior below, on reception of the signal you would call
/// `LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug`, for example.
///
/// ```swift
/// import class Foundation.NSLock
///
/// public struct LogHandlerWithGlobalLogLevelOverride: LogHandler {
/// // the static properties hold the globally overridden log level (if overridden)
/// private static let overrideLock = NSLock()
/// private static var overrideLogLevel: Logger.Level? = nil
///
/// // this holds the log level if not overridden
/// private var _logLevel: Logger.Level = .info
///
/// // metadata storage
/// public var metadata: Logger.Metadata = [:]
///
/// public init(label: String) {
/// // [...]
/// }
///
/// public var logLevel: Logger.Level {
/// // when we get asked for the log level, we check if it was globally overridden or not
/// get {
/// LogHandlerWithGlobalLogLevelOverride.overrideLock.lock()
/// defer { LogHandlerWithGlobalLogLevelOverride.overrideLock.unlock() }
/// return LogHandlerWithGlobalLogLevelOverride.overrideLogLevel ?? self._logLevel
/// }
/// // we set the log level whenever we're asked (note: this might not have an effect if globally
/// // overridden)
/// set {
/// self._logLevel = newValue
/// }
/// }
///
/// public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?,
/// source: String, file: String, function: String, line: UInt) {
/// // [...]
/// }
///
/// public subscript(metadataKey metadataKey: String) -> Logger.Metadata.Value? {
/// get {
/// return self.metadata[metadataKey]
/// }
/// set(newValue) {
/// self.metadata[metadataKey] = newValue
/// }
/// }
///
/// // this is the function to globally override the log level, it is not part of the `LogHandler` protocol
/// public static func overrideGlobalLogLevel(_ logLevel: Logger.Level) {
/// LogHandlerWithGlobalLogLevelOverride.overrideLock.lock()
/// defer { LogHandlerWithGlobalLogLevelOverride.overrideLock.unlock() }
/// LogHandlerWithGlobalLogLevelOverride.overrideLogLevel = logLevel
/// }
/// }
/// ```
///
/// Please note that the above `LogHandler` will still pass the 'log level is a value' test above it iff the global log
/// level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
/// level on one `Logger` should not affect the log level of another `Logger` variable.
public protocol LogHandler: _SwiftLogSendableLogHandler {
/// The metadata provider this `LogHandler` will use when a log statement is about to be emitted.
///
/// A ``Logger/MetadataProvider`` may add a constant set of metadata,
/// or use task-local values to pick up contextual metadata and add it to emitted logs.
var metadataProvider: Logger.MetadataProvider? { get set }
/// This method is called when a `LogHandler` must emit a log message. There is no need for the `LogHandler` to
/// check if the `level` is above or below the configured `logLevel` as `Logger` already performed this check and
/// determined that a message should be logged.
///
/// - parameters:
/// - level: The log level the message was logged at.
/// - message: The message to log. To obtain a `String` representation call `message.description`.
/// - metadata: The metadata associated to this log message.
/// - source: The source where the log message originated, for example the logging module.
/// - file: The file the log message was emitted from.
/// - function: The function the log line was emitted from.
/// - line: The line the log message was emitted from.
func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
)
/// SwiftLog 1.0 compatibility method. Please do _not_ implement, implement
/// `log(level:message:metadata:source:file:function:line:)` instead.
@available(*, deprecated, renamed: "log(level:message:metadata:source:file:function:line:)")
func log(
level: Logging.Logger.Level,
message: Logging.Logger.Message,
metadata: Logging.Logger.Metadata?,
file: String,
function: String,
line: UInt
)
/// Add, remove, or change the logging metadata.
///
/// - note: `LogHandler`s must treat logging metadata as a value type. This means that the change in metadata must
/// only affect this very `LogHandler`.
///
/// - parameters:
/// - metadataKey: The key for the metadata item
subscript(metadataKey _: String) -> Logger.Metadata.Value? { get set }
/// Get or set the entire metadata storage as a dictionary.
///
/// - note: `LogHandler`s must treat logging metadata as a value type. This means that the change in metadata must
/// only affect this very `LogHandler`.
var metadata: Logger.Metadata { get set }
/// Get or set the configured log level.
///
/// - note: `LogHandler`s must treat the log level as a value type. This means that the change in metadata must
/// only affect this very `LogHandler`. It is acceptable to provide some form of global log level override
/// that means a change in log level on a particular `LogHandler` might not be reflected in any
/// `LogHandler`.
var logLevel: Logger.Level { get set }
}
extension LogHandler {
/// Default implementation for `metadataProvider` which defaults to `nil`.
/// This default exists in order to facilitate source-compatible introduction of the `metadataProvider` protocol requirement.
public var metadataProvider: Logger.MetadataProvider? {
get {
nil
}
set {
#if DEBUG
if LoggingSystem.warnOnceLogHandlerNotSupportedMetadataProvider(Self.self) {
self.log(
level: .warning,
message:
"Attempted to set metadataProvider on \(Self.self) that did not implement support for them. Please contact the log handler maintainer to implement metadata provider support.",
metadata: nil,
source: "Logging",
file: #file,
function: #function,
line: #line
)
}
#endif
}
}
}
extension LogHandler {
@available(*, deprecated, message: "You should implement this method instead of using the default implementation")
public func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
self.log(level: level, message: message, metadata: metadata, file: file, function: function, line: line)
}
@available(*, deprecated, renamed: "log(level:message:metadata:source:file:function:line:)")
public func log(
level: Logging.Logger.Level,
message: Logging.Logger.Message,
metadata: Logging.Logger.Metadata?,
file: String,
function: String,
line: UInt
) {
self.log(
level: level,
message: message,
metadata: metadata,
source: Logger.currentModule(filePath: file),
file: file,
function: function,
line: line
)
}
}
// MARK: - Sendable support helpers
@preconcurrency public protocol _SwiftLogSendableLogHandler: Sendable {}
File diff suppressed because it is too large. Load diff
+101
View File
@@ -0,0 +1,101 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2022 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if canImport(Darwin)
import Darwin
#elseif os(Windows)
import CRT
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Android)
import Android
#elseif canImport(Musl)
import Musl
#elseif canImport(WASILibc)
import WASILibc
#else
#error("Unsupported runtime")
#endif
@preconcurrency protocol _SwiftLogSendable: Sendable {}
extension Logger {
/// A `MetadataProvider` is used to automatically inject runtime-generated metadata
/// to all logs emitted by a logger.
///
/// ### Example
/// A metadata provider may be used to automatically inject metadata such as
/// trace IDs:
///
/// ```swift
/// import Tracing // https://github.com/apple/swift-distributed-tracing
///
/// let metadataProvider = MetadataProvider {
/// guard let traceID = Baggage.current?.traceID else { return nil }
/// return ["traceID": "\(traceID)"]
/// }
/// let logger = Logger(label: "example", metadataProvider: metadataProvider)
/// var baggage = Baggage.topLevel
/// baggage.traceID = 42
/// Baggage.withValue(baggage) {
/// logger.info("hello") // automatically includes ["traceID": "42"] metadata
/// }
/// ```
///
/// We recommend referring to [swift-distributed-tracing](https://github.com/apple/swift-distributed-tracing)
/// for metadata providers which make use of its tracing and metadata propagation infrastructure. It is however
/// possible to make use of metadata providers independently of tracing and instruments provided by that library,
/// if necessary.
public struct MetadataProvider: _SwiftLogSendable {
/// Provide ``Logger.Metadata`` from current context.
@usableFromInline
internal let _provideMetadata: @Sendable () -> Metadata
/// Create a new `MetadataProvider`.
///
/// - Parameter provideMetadata: A closure extracting metadata from the current execution context.
public init(_ provideMetadata: @escaping @Sendable () -> Metadata) {
self._provideMetadata = provideMetadata
}
/// Invoke the metadata provider and return the generated contextual ``Logger/Metadata``.
public func get() -> Metadata {
self._provideMetadata()
}
}
}
extension Logger.MetadataProvider {
/// A pseudo-`MetadataProvider` that can be used to merge metadata from multiple other `MetadataProvider`s.
///
/// ### Merging conflicting keys
///
/// `MetadataProvider`s are invoked left to right in the order specified in the `providers` argument.
/// In case multiple providers try to add a value for the same key, the last provider "wins" and its value is being used.
///
/// - Parameter providers: An array of `MetadataProvider`s to delegate to. The array must not be empty.
/// - Returns: A pseudo-`MetadataProvider` merging metadata from the given `MetadataProvider`s.
public static func multiplex(_ providers: [Logger.MetadataProvider]) -> Logger.MetadataProvider? {
assert(!providers.isEmpty, "providers MUST NOT be empty")
return Logger.MetadataProvider {
providers.reduce(into: [:]) { metadata, provider in
let providedMetadata = provider.get()
guard !providedMetadata.isEmpty else {
return
}
metadata.merge(providedMetadata, uniquingKeysWith: { _, rhs in rhs })
}
}
}
}
@@ -0,0 +1,98 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
// Not testable
import Logging
import XCTest
final class CompatibilityTest: XCTestCase {
@available(*, deprecated, message: "Testing deprecated functionality")
func testAllLogLevelsWorkWithOldSchoolLogHandlerWorks() {
let testLogging = OldSchoolTestLogging()
var logger = Logger(label: "\(#function)", factory: { testLogging.make(label: $0) })
logger.logLevel = .trace
logger.trace("yes: trace")
logger.debug("yes: debug")
logger.info("yes: info")
logger.notice("yes: notice")
logger.warning("yes: warning")
logger.error("yes: error")
logger.critical("yes: critical", source: "any also with some new argument that isn't propagated")
// Please note that the source is _not_ propagated (because the backend doesn't support it).
testLogging.history.assertExist(level: .trace, message: "yes: trace", source: "no source")
testLogging.history.assertExist(level: .debug, message: "yes: debug", source: "no source")
testLogging.history.assertExist(level: .info, message: "yes: info", source: "no source")
testLogging.history.assertExist(level: .notice, message: "yes: notice", source: "no source")
testLogging.history.assertExist(level: .warning, message: "yes: warning", source: "no source")
testLogging.history.assertExist(level: .error, message: "yes: error", source: "no source")
testLogging.history.assertExist(level: .critical, message: "yes: critical", source: "no source")
}
}
private struct OldSchoolTestLogging {
private let _config = Config() // shared among loggers
private let recorder = Recorder() // shared among loggers
@available(*, deprecated, message: "Testing deprecated functionality")
func make(label: String) -> any LogHandler {
OldSchoolLogHandler(
label: label,
config: self.config,
recorder: self.recorder,
metadata: [:],
logLevel: .info
)
}
var config: Config { self._config }
var history: some History { self.recorder }
}
@available(*, deprecated, message: "Testing deprecated functionality")
private struct OldSchoolLogHandler: LogHandler {
var label: String
let config: Config
let recorder: Recorder
func make(label: String) -> some LogHandler {
TestLogHandler(label: label, config: self.config, recorder: self.recorder)
}
func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
file: String,
function: String,
line: UInt
) {
self.recorder.record(level: level, metadata: metadata, message: message, source: "no source")
}
subscript(metadataKey metadataKey: String) -> Logger.Metadata.Value? {
get {
self.metadata[metadataKey]
}
set {
self.metadata[metadataKey] = newValue
}
}
var metadata: Logger.Metadata
var logLevel: Logger.Level
}
+188
View File
@@ -0,0 +1,188 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Logging
#if compiler(>=6.0) || canImport(Darwin)
import Dispatch
#else
@preconcurrency import Dispatch
#endif
class GlobalLoggerTest: XCTestCase {
func test1() throws {
// bootstrap with our test logging impl
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// change test logging config to log traces and above
logging.config.set(value: Logger.Level.debug)
// run our program
Struct1().doSomething()
// test results
logging.history.assertExist(level: .debug, message: "Struct1::doSomething")
logging.history.assertExist(level: .debug, message: "Struct1::doSomethingElse")
logging.history.assertExist(level: .info, message: "Struct2::doSomething")
logging.history.assertExist(level: .info, message: "Struct2::doSomethingElse")
logging.history.assertExist(level: .error, message: "Struct3::doSomething")
logging.history.assertExist(level: .error, message: "Struct3::doSomethingElse", metadata: ["foo": "bar"])
logging.history.assertExist(level: .warning, message: "Struct3::doSomethingElseAsync", metadata: ["foo": "bar"])
logging.history.assertExist(level: .info, message: "TestLibrary::doSomething", metadata: ["foo": "bar"])
logging.history.assertExist(level: .info, message: "TestLibrary::doSomethingAsync", metadata: ["foo": "bar"])
logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::Local", metadata: ["baz": "qux"])
logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::end")
logging.history.assertExist(level: .debug, message: "Struct3::doSomething::end")
logging.history.assertExist(level: .debug, message: "Struct2::doSomethingElse::end")
logging.history.assertExist(level: .debug, message: "Struct1::doSomethingElse::end")
logging.history.assertExist(level: .debug, message: "Struct1::doSomething::end")
}
func test2() throws {
// bootstrap with our test logging impl
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// change test logging config to log errors and above
logging.config.set(value: Logger.Level.error)
// run our program
Struct1().doSomething()
// test results
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse")
logging.history.assertNotExist(level: .info, message: "Struct2::doSomething")
logging.history.assertNotExist(level: .info, message: "Struct2::doSomethingElse")
logging.history.assertExist(level: .error, message: "Struct3::doSomething")
logging.history.assertExist(level: .error, message: "Struct3::doSomethingElse", metadata: ["foo": "bar"])
logging.history.assertNotExist(
level: .warning,
message: "Struct3::doSomethingElseAsync",
metadata: ["foo": "bar"]
)
logging.history.assertNotExist(level: .info, message: "TestLibrary::doSomething", metadata: ["foo": "bar"])
logging.history.assertNotExist(level: .info, message: "TestLibrary::doSomethingAsync", metadata: ["foo": "bar"])
logging.history.assertNotExist(
level: .debug,
message: "Struct3::doSomethingElse::Local",
metadata: ["baz": "qux"]
)
logging.history.assertNotExist(level: .debug, message: "Struct3::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct3::doSomething::end")
logging.history.assertNotExist(level: .debug, message: "Struct2::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething::end")
}
func test3() throws {
// bootstrap with our test logging impl
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// change test logging config
logging.config.set(value: .warning)
logging.config.set(key: "GlobalLoggerTest::Struct2", value: .info)
logging.config.set(key: "TestLibrary", value: .debug)
// run our program
Struct1().doSomething()
// test results
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse")
logging.history.assertExist(level: .info, message: "Struct2::doSomething")
logging.history.assertExist(level: .info, message: "Struct2::doSomethingElse")
logging.history.assertExist(level: .error, message: "Struct3::doSomething")
logging.history.assertExist(level: .error, message: "Struct3::doSomethingElse", metadata: ["foo": "bar"])
logging.history.assertExist(level: .warning, message: "Struct3::doSomethingElseAsync", metadata: ["foo": "bar"])
logging.history.assertExist(level: .info, message: "TestLibrary::doSomething", metadata: ["foo": "bar"])
logging.history.assertExist(level: .info, message: "TestLibrary::doSomethingAsync", metadata: ["foo": "bar"])
logging.history.assertNotExist(
level: .debug,
message: "Struct3::doSomethingElse::Local",
metadata: ["baz": "qux"]
)
logging.history.assertNotExist(level: .debug, message: "Struct3::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct3::doSomething::end")
logging.history.assertNotExist(level: .debug, message: "Struct2::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse::end")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething::end")
}
}
private struct Struct1 {
private let logger = Logger(label: "GlobalLoggerTest::Struct1")
func doSomething() {
self.logger.debug("Struct1::doSomething")
self.doSomethingElse()
self.logger.debug("Struct1::doSomething::end")
}
private func doSomethingElse() {
self.logger.debug("Struct1::doSomethingElse")
Struct2().doSomething()
self.logger.debug("Struct1::doSomethingElse::end")
}
}
private struct Struct2 {
let logger = Logger(label: "GlobalLoggerTest::Struct2")
func doSomething() {
self.logger.info("Struct2::doSomething")
self.doSomethingElse()
self.logger.debug("Struct2::doSomething::end")
}
private func doSomethingElse() {
self.logger.info("Struct2::doSomethingElse")
Struct3().doSomething()
self.logger.debug("Struct2::doSomethingElse::end")
}
}
private struct Struct3 {
private let logger = Logger(label: "GlobalLoggerTest::Struct3")
private let queue = DispatchQueue(label: "GlobalLoggerTest::Struct3")
func doSomething() {
self.logger.error("Struct3::doSomething")
self.doSomethingElse()
self.logger.debug("Struct3::doSomething::end")
}
private func doSomethingElse() {
MDC.global["foo"] = "bar"
self.logger.error("Struct3::doSomethingElse")
let group = DispatchGroup()
group.enter()
let loggingMetadata = MDC.global.metadata
self.queue.async {
MDC.global.with(metadata: loggingMetadata) {
self.logger.warning("Struct3::doSomethingElseAsync")
let library = TestLibrary()
library.doSomething()
library.doSomethingAsync {
group.leave()
}
}
}
group.wait()
MDC.global["foo"] = nil
// only effects the logger instance
var l = self.logger
l[metadataKey: "baz"] = "qux"
l.debug("Struct3::doSomethingElse::Local")
self.logger.debug("Struct3::doSomethingElse::end")
}
}
+188
View File
@@ -0,0 +1,188 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Logging
#if compiler(>=6.0) || canImport(Darwin)
import Dispatch
#else
@preconcurrency import Dispatch
#endif
class LocalLoggerTest: XCTestCase {
func test1() throws {
// bootstrap with our test logging impl
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// change test logging config to log traces and above
logging.config.set(value: Logger.Level.debug)
// run our program
let context = Context()
Struct1().doSomething(context: context)
// test results
logging.history.assertExist(level: .debug, message: "Struct1::doSomething", source: "LoggingTests")
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse")
logging.history.assertExist(level: .info, message: "Struct2::doSomething")
logging.history.assertExist(level: .info, message: "Struct2::doSomethingElse")
logging.history.assertExist(level: .error, message: "Struct3::doSomething", metadata: ["bar": "baz"])
logging.history.assertExist(level: .error, message: "Struct3::doSomethingElse", metadata: ["bar": "baz"])
logging.history.assertExist(level: .warning, message: "Struct3::doSomethingElseAsync", metadata: ["bar": "baz"])
logging.history.assertExist(level: .info, message: "TestLibrary::doSomething")
logging.history.assertExist(level: .info, message: "TestLibrary::doSomethingAsync")
logging.history.assertExist(
level: .debug,
message: "Struct3::doSomethingElse::Local",
metadata: ["bar": "baz", "baz": "qux"]
)
logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::end", metadata: ["bar": "baz"])
logging.history.assertExist(level: .debug, message: "Struct3::doSomething::end", metadata: ["bar": "baz"])
logging.history.assertExist(level: .debug, message: "Struct2::doSomethingElse::end")
logging.history.assertExist(level: .debug, message: "Struct1::doSomethingElse::end")
logging.history.assertExist(level: .debug, message: "Struct1::doSomething::end")
}
func test2() throws {
// bootstrap with our test logging impl
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// change test logging config to log errors and above
logging.config.set(value: Logger.Level.error)
// run our program
let context = Context()
Struct1().doSomething(context: context)
// test results
// global context
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething")
// global context
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse")
// local context
logging.history.assertExist(level: .info, message: "Struct2::doSomething")
// local context
logging.history.assertExist(level: .info, message: "Struct2::doSomethingElse")
// local context
logging.history.assertExist(level: .error, message: "Struct3::doSomething", metadata: ["bar": "baz"])
// local context
logging.history.assertExist(level: .error, message: "Struct3::doSomethingElse", metadata: ["bar": "baz"])
// local context
logging.history.assertExist(level: .warning, message: "Struct3::doSomethingElseAsync", metadata: ["bar": "baz"])
// global context
logging.history.assertNotExist(level: .info, message: "TestLibrary::doSomething")
// global context
logging.history.assertNotExist(level: .info, message: "TestLibrary::doSomethingAsync")
// hyper local context
logging.history.assertExist(
level: .debug,
message: "Struct3::doSomethingElse::Local",
metadata: ["bar": "baz", "baz": "qux"]
)
// local context
logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::end", metadata: ["bar": "baz"])
// local context
logging.history.assertExist(level: .debug, message: "Struct2::doSomethingElse::end")
// local context
logging.history.assertExist(level: .debug, message: "Struct3::doSomething::end", metadata: ["bar": "baz"])
// global context
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse::end")
// global context
logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething::end")
}
}
// systems that follow the context pattern need to implement something like this
private struct Context {
var logger = Logger(label: "LocalLoggerTest::ContextLogger")
// since logger is a value type, we can reuse our copy to manage logLevel
var logLevel: Logger.Level {
get { self.logger.logLevel }
set { self.logger.logLevel = newValue }
}
// since logger is a value type, we can reuse our copy to manage metadata
subscript(metadataKey: String) -> Logger.Metadata.Value? {
get { self.logger[metadataKey: metadataKey] }
set { self.logger[metadataKey: metadataKey] = newValue }
}
}
private struct Struct1 {
func doSomething(context: Context) {
context.logger.debug("Struct1::doSomething")
self.doSomethingElse(context: context)
context.logger.debug("Struct1::doSomething::end")
}
private func doSomethingElse(context: Context) {
let originalContext = context
var context = context
context.logger.logLevel = .warning
context.logger.debug("Struct1::doSomethingElse")
Struct2().doSomething(context: context)
originalContext.logger.debug("Struct1::doSomethingElse::end")
}
}
private struct Struct2 {
func doSomething(context: Context) {
var c = context
c.logLevel = .info // only effects from this point on
c.logger.info("Struct2::doSomething")
self.doSomethingElse(context: c)
c.logger.debug("Struct2::doSomething::end")
}
private func doSomethingElse(context: Context) {
var c = context
c.logLevel = .debug // only effects from this point on
c.logger.info("Struct2::doSomethingElse")
Struct3().doSomething(context: c)
c.logger.debug("Struct2::doSomethingElse::end")
}
}
private struct Struct3 {
private let queue = DispatchQueue(label: "LocalLoggerTest::Struct3")
func doSomething(context: Context) {
var c = context
c["bar"] = "baz" // only effects from this point on
c.logger.error("Struct3::doSomething")
self.doSomethingElse(context: c)
c.logger.debug("Struct3::doSomething::end")
}
private func doSomethingElse(context: Context) {
context.logger.error("Struct3::doSomethingElse")
let group = DispatchGroup()
group.enter()
self.queue.async {
context.logger.warning("Struct3::doSomethingElseAsync")
let library = TestLibrary()
library.doSomething()
library.doSomethingAsync {
group.leave()
}
}
group.wait()
// only effects the logger instance
var l = context.logger
l[metadataKey: "baz"] = "qux"
l.debug("Struct3::doSomethingElse::Local")
context.logger.debug("Struct3::doSomethingElse::end")
}
}
File diff suppressed because it is too large. Load diff
+55
View File
@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Dispatch
import XCTest
@testable import Logging
class MDCTest: XCTestCase {
func test1() throws {
// bootstrap with our test logger
let logging = TestLogging()
LoggingSystem.bootstrapInternal { logging.make(label: $0) }
// run the program
MDC.global["foo"] = "bar"
let group = DispatchGroup()
for r in 5...10 {
group.enter()
DispatchQueue(label: "mdc-test-queue-\(r)").async {
let add = Int.random(in: 10...1000)
let remove = Int.random(in: 0...add - 1)
for i in 0...add {
MDC.global["key-\(i)"] = "value-\(i)"
}
for i in 0...remove {
MDC.global["key-\(i)"] = nil
}
XCTAssertEqual(add - remove, MDC.global.metadata.count, "expected number of entries to match")
for i in remove + 1...add {
XCTAssertNotNil(MDC.global["key-\(i)"], "expecting value for key-\(i)")
}
for i in 0...remove {
XCTAssertNil(MDC.global["key-\(i)"], "not expecting value for key-\(i)")
}
MDC.global.clear()
group.leave()
}
}
group.wait()
XCTAssertEqual(MDC.global["foo"], "bar", "expecting to find top items")
MDC.global["foo"] = nil
XCTAssertTrue(MDC.global.metadata.isEmpty, "MDC should be empty")
}
}
@@ -0,0 +1,185 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Logging
#if canImport(Darwin)
import Darwin
#elseif os(Windows)
import WinSDK
#elseif canImport(Android)
import Android
#else
import Glibc
#endif
final class MetadataProviderTest: XCTestCase {
func testLoggingMergesOneOffMetadataWithProvidedMetadataFromExplicitlyPassed() throws {
let logging = TestLogging()
LoggingSystem.bootstrapInternal(
{ logging.makeWithMetadataProvider(label: $0, metadataProvider: $1) },
metadataProvider: .init {
["common": "initial"]
}
)
let logger = Logger(
label: #function,
metadataProvider: .init {
[
"common": "provider",
"provider": "42",
]
}
)
logger.log(level: .info, "test", metadata: ["one-off": "42", "common": "one-off"])
logging.history.assertExist(
level: .info,
message: "test",
metadata: ["common": "one-off", "one-off": "42", "provider": "42"]
)
}
func testLogHandlerThatDidNotImplementProvidersButSomeoneAttemptsToSetOneOnIt() {
#if DEBUG
// we only emit these warnings in debug mode
let logging = TestLogging()
var handler = LogHandlerThatDidNotImplementMetadataProviders(testLogging: logging)
handler.metadataProvider = .simpleTestProvider
logging.history.assertExist(
level: .warning,
message:
"Attempted to set metadataProvider on LogHandlerThatDidNotImplementMetadataProviders that did not implement support for them. Please contact the log handler maintainer to implement metadata provider support.",
source: "Logging"
)
let countBefore = logging.history.entries.count
handler.metadataProvider = .simpleTestProvider
XCTAssertEqual(countBefore, logging.history.entries.count, "Should only log the warning once")
#endif
}
func testLogHandlerThatDidImplementProvidersButSomeoneAttemptsToSetOneOnIt() {
#if DEBUG
// we only emit these warnings in debug mode
let logging = TestLogging()
var handler = LogHandlerThatDidImplementMetadataProviders(testLogging: logging)
handler.metadataProvider = .simpleTestProvider
logging.history.assertNotExist(
level: .warning,
message:
"Attempted to set metadataProvider on LogHandlerThatDidImplementMetadataProviders that did not implement support for them. Please contact the log handler maintainer to implement metadata provider support.",
source: "Logging"
)
#endif
}
}
extension Logger.MetadataProvider {
static var simpleTestProvider: Logger.MetadataProvider {
Logger.MetadataProvider {
["test": "provided"]
}
}
}
public struct LogHandlerThatDidNotImplementMetadataProviders: LogHandler {
let testLogging: TestLogging
init(testLogging: TestLogging) {
self.testLogging = testLogging
}
public subscript(metadataKey _: String) -> Logging.Logger.Metadata.Value? {
get {
nil
}
set(newValue) {
// ignore
}
}
public var metadata: Logging.Logger.Metadata = [:]
public var logLevel: Logging.Logger.Level = .trace
public func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
self.testLogging.make(label: "fake").log(
level: level,
message: message,
metadata: metadata,
source: source,
file: file,
function: function,
line: line
)
}
}
public struct LogHandlerThatDidImplementMetadataProviders: LogHandler {
let testLogging: TestLogging
init(testLogging: TestLogging) {
self.testLogging = testLogging
}
public subscript(metadataKey _: String) -> Logging.Logger.Metadata.Value? {
get {
nil
}
set(newValue) {
// ignore
}
}
public var metadata: Logging.Logger.Metadata = [:]
public var logLevel: Logging.Logger.Level = .trace
public var metadataProvider: Logger.MetadataProvider?
public func log(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
self.testLogging.make(label: "fake").log(
level: level,
message: message,
metadata: metadata,
source: source,
file: file,
function: function,
line: line
)
}
}
@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Logging
internal func emitLogMessage(_ message: Logger.Message, to logger: Logger) {
logger.trace(message)
logger.debug(message)
logger.info(message)
logger.notice(message)
logger.warning(message)
logger.error(message)
logger.critical(message)
}
+425
View File
@@ -0,0 +1,425 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
import XCTest
@testable import Logging
#if os(Windows)
import WinSDK
#endif
#if compiler(>=6.0) || canImport(Darwin)
import Dispatch
#else
@preconcurrency import Dispatch
#endif
internal struct TestLogging {
private let _config = Config() // shared among loggers
private let recorder = Recorder() // shared among loggers
func make(label: String) -> some LogHandler {
TestLogHandler(
label: label,
config: self.config,
recorder: self.recorder,
metadataProvider: LoggingSystem.metadataProvider
)
}
func makeWithMetadataProvider(label: String, metadataProvider: Logger.MetadataProvider?) -> (some LogHandler) {
TestLogHandler(
label: label,
config: self.config,
recorder: self.recorder,
metadataProvider: metadataProvider
)
}
var config: Config { self._config }
var history: some History { self.recorder }
}
internal struct TestLogHandler: LogHandler {
private let recorder: Recorder
private let config: Config
private var logger: Logger // the actual logger
let label: String
public var metadataProvider: Logger.MetadataProvider?
init(label: String, config: Config, recorder: Recorder, metadataProvider: Logger.MetadataProvider?) {
self.label = label
self.config = config
self.recorder = recorder
self.logger = Logger(label: "test", StreamLogHandler.standardOutput(label: label))
self.logger.logLevel = .debug
self.metadataProvider = metadataProvider
}
init(label: String, config: Config, recorder: Recorder) {
self.label = label
self.config = config
self.recorder = recorder
self.logger = Logger(label: "test", StreamLogHandler.standardOutput(label: label))
self.logger.logLevel = .debug
self.metadataProvider = LoggingSystem.metadataProvider
}
func log(
level: Logger.Level,
message: Logger.Message,
metadata explicitMetadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt
) {
// baseline metadata, that was set on handler:
var metadata = self._metadataSet ? self.metadata : MDC.global.metadata
// contextual metadata, e.g. from task-locals:
let contextualMetadata = self.metadataProvider?.get() ?? [:]
if !contextualMetadata.isEmpty {
metadata.merge(contextualMetadata, uniquingKeysWith: { _, contextual in contextual })
}
// override using any explicit metadata passed for this log statement:
if let explicitMetadata = explicitMetadata {
metadata.merge(explicitMetadata, uniquingKeysWith: { _, explicit in explicit })
}
self.logger.log(
level: level,
message,
metadata: metadata,
source: source,
file: file,
function: function,
line: line
)
self.recorder.record(level: level, metadata: metadata, message: message, source: source)
}
private var _logLevel: Logger.Level?
var logLevel: Logger.Level {
get {
// get from config unless set
self._logLevel ?? self.config.get(key: self.label)
}
set {
self._logLevel = newValue
}
}
private var _metadataSet = false
private var _metadata = Logger.Metadata() {
didSet {
self._metadataSet = true
}
}
public var metadata: Logger.Metadata {
get {
self._metadata
}
set {
self._metadata = newValue
}
}
// TODO: would be nice to delegate to local copy of logger but StdoutLogger is a reference type. why?
subscript(metadataKey metadataKey: Logger.Metadata.Key) -> Logger.Metadata.Value? {
get {
self._metadata[metadataKey]
}
set {
self._metadata[metadataKey] = newValue
}
}
}
internal class Config {
private static let ALL = "*"
private let lock = NSLock()
private var storage = [String: Logger.Level]()
func get(key: String) -> Logger.Level {
self.get(key) ?? self.get(Config.ALL) ?? Logger.Level.debug
}
func get(_ key: String) -> Logger.Level? {
guard let value = (self.lock.withLock { self.storage[key] }) else {
return nil
}
return value
}
func set(key: String = Config.ALL, value: Logger.Level) {
self.lock.withLock { self.storage[key] = value }
}
func clear() {
self.lock.withLock { self.storage.removeAll() }
}
}
internal class Recorder: History {
private let lock = NSLock()
private var _entries = [LogEntry]()
func record(level: Logger.Level, metadata: Logger.Metadata?, message: Logger.Message, source: String) {
self.lock.withLock {
self._entries.append(
LogEntry(level: level, metadata: metadata, message: message.description, source: source)
)
}
}
var entries: [LogEntry] {
self.lock.withLock { self._entries }
}
}
internal protocol History {
var entries: [LogEntry] { get }
}
extension History {
func atLevel(level: Logger.Level) -> [LogEntry] {
self.entries.filter { entry in
level == entry.level
}
}
var trace: [LogEntry] {
self.atLevel(level: .debug)
}
var debug: [LogEntry] {
self.atLevel(level: .debug)
}
var info: [LogEntry] {
self.atLevel(level: .info)
}
var warning: [LogEntry] {
self.atLevel(level: .warning)
}
var error: [LogEntry] {
self.atLevel(level: .error)
}
}
internal struct LogEntry {
let level: Logger.Level
let metadata: Logger.Metadata?
let message: String
let source: String
}
extension History {
func assertExist(
level: Logger.Level,
message: String,
metadata: Logger.Metadata? = nil,
source: String? = nil,
file: StaticString = #filePath,
fileID: String = #fileID,
line: UInt = #line
) {
let source = source ?? Logger.currentModule(fileID: "\(fileID)")
let entry = self.find(level: level, message: message, metadata: metadata, source: source)
XCTAssertNotNil(
entry,
"entry not found: \(level), \(source), \(String(describing: metadata)), \(message)",
file: file,
line: line
)
}
func assertNotExist(
level: Logger.Level,
message: String,
metadata: Logger.Metadata? = nil,
source: String? = nil,
file: StaticString = #filePath,
fileID: String = #file,
line: UInt = #line
) {
let source = source ?? Logger.currentModule(fileID: "\(fileID)")
let entry = self.find(level: level, message: message, metadata: metadata, source: source)
XCTAssertNil(
entry,
"entry was found: \(level), \(source), \(String(describing: metadata)), \(message)",
file: file,
line: line
)
}
func find(level: Logger.Level, message: String, metadata: Logger.Metadata? = nil, source: String) -> LogEntry? {
self.entries.first { entry in
if entry.level != level {
return false
}
if entry.message != message {
return false
}
if let lhs = entry.metadata, let rhs = metadata {
if lhs.count != rhs.count {
return false
}
for lk in lhs.keys {
if lhs[lk] != rhs[lk] {
return false
}
}
for rk in rhs.keys {
if lhs[rk] != rhs[rk] {
return false
}
}
return true
}
if entry.source != source {
return false
}
return true
}
}
}
public class MDC {
private let lock = NSLock()
private var storage = [Int: Logger.Metadata]()
public static let global = MDC()
private init() {}
public subscript(metadataKey: String) -> Logger.Metadata.Value? {
get {
self.lock.withLock {
self.storage[self.threadId]?[metadataKey]
}
}
set {
self.lock.withLock {
if self.storage[self.threadId] == nil {
self.storage[self.threadId] = Logger.Metadata()
}
self.storage[self.threadId]![metadataKey] = newValue
}
}
}
public var metadata: Logger.Metadata {
self.lock.withLock {
self.storage[self.threadId] ?? [:]
}
}
public func clear() {
self.lock.withLock {
_ = self.storage.removeValue(forKey: self.threadId)
}
}
public func with(metadata: Logger.Metadata, _ body: () throws -> Void) rethrows {
for (key, value) in metadata {
self[key] = value
}
defer {
for (key, _) in metadata {
self[key] = nil
}
}
try body()
}
public func with<T>(metadata: Logger.Metadata, _ body: () throws -> T) rethrows -> T {
for (key, value) in metadata {
self[key] = value
}
defer {
for (key, _) in metadata {
self[key] = nil
}
}
return try body()
}
// for testing
internal func flush() {
self.lock.withLock {
self.storage.removeAll()
}
}
private var threadId: Int {
#if canImport(Darwin)
return Int(pthread_mach_thread_np(pthread_self()))
#elseif os(Windows)
return Int(GetCurrentThreadId())
#else
return Int(pthread_self())
#endif
}
}
extension NSLock {
func withLock<T>(_ body: () -> T) -> T {
self.lock()
defer {
self.unlock()
}
return body()
}
}
internal struct TestLibrary: Sendable {
private let logger = Logger(label: "TestLibrary")
private let queue = DispatchQueue(label: "TestLibrary")
public init() {}
public func doSomething() {
self.logger.info("TestLibrary::doSomething")
}
public func doSomethingAsync(completion: @escaping @Sendable () -> Void) {
// libraries that use global loggers and async, need to make sure they propagate the
// logging metadata when creating a new thread
let metadata = MDC.global.metadata
self.queue.asyncAfter(deadline: .now() + 0.1) {
MDC.global.with(metadata: metadata) {
self.logger.info("TestLibrary::doSomethingAsync")
completion()
}
}
}
}
// Sendable
extension TestLogHandler: @unchecked Sendable {}
extension Recorder: @unchecked Sendable {}
extension Config: @unchecked Sendable {}
extension MDC: @unchecked Sendable {}
+42
View File
@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Logging API open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift Logging API project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Logging API project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Logging
class SendableTest: XCTestCase {
func testSendableLogger() async {
let testLogging = TestLogging()
LoggingSystem.bootstrapInternal { testLogging.make(label: $0) }
let logger = Logger(label: "test")
let message1 = Logger.Message(stringLiteral: "critical 1")
let message2 = Logger.Message(stringLiteral: "critical 2")
let metadata: Logger.Metadata = ["key": "value"]
let task = Task.detached {
logger.info("info")
logger.critical(message1)
logger.critical(message2)
logger.warning(.init(stringLiteral: "warning"), metadata: metadata)
}
await task.value
testLogging.history.assertExist(level: .info, message: "info", metadata: [:])
testLogging.history.assertExist(level: .critical, message: "critical 1", metadata: [:])
testLogging.history.assertExist(level: .critical, message: "critical 2", metadata: [:])
testLogging.history.assertExist(level: .warning, message: "warning", metadata: metadata)
}
}
+14
View File
@@ -0,0 +1,14 @@
One line description of your change
Motivation:
Explain here the context, and why you're making that change.
What is the problem you're trying to solve.
Modifications:
Describe the modifications you've done.
Result:
After your change, what will change.
-154
View File
@@ -1,154 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Enumerations Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Enumerations" class="dashAnchor"></a>
<a title="Enumerations Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Enumerations Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Enumerations</h1>
<p>The following enumerations are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO"></a>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO">LoggingSystem</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
<a href="Enums/LoggingSystem.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L259-L284">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-180
View File
@@ -1,180 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LoggingSystem Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a title="LoggingSystem Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
LoggingSystem Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>LoggingSystem</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="../Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ"></a>
<a name="//apple_ref/swift/Method/bootstrap(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ">bootstrap(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>bootstrap</code> is a one-time configuration function which globally selects the desired logging backend
implementation. <code>bootstrap</code> can be called at maximum once in any given program, calling it more than once will
lead to undefined behaviour, most likely a crash.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">bootstrap</span><span class="p">(</span><span class="n">_</span> <span class="nv">factory</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>factory</em>
</code>
</td>
<td>
<div>
<p>A closure that given a <code><a href="../Structs/Logger.html">Logger</a></code> identifier, produces an instance of the <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L270-L276">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-245
View File
@@ -1,245 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Protocols Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Protocols" class="dashAnchor"></a>
<a title="Protocols Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Protocols Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Protocols</h1>
<p>The following protocols are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP"></a>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP">LogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">Lock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span>
<span class="p">}</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="Structs/Logger.html">Logger</a></code> variable.</p>
<a href="Protocols/LogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/LogHandler.swift#L114-L153">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,460 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LogHandler Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a title="LogHandler Protocol Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
LogHandler Protocol Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>LogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="../Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="../Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="../Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="../Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="../Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">Lock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span>
<span class="p">}</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="../Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="../Structs/Logger.html">Logger</a></code> variable.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>This method is called when a <code>LogHandler</code> must emit a log message. There is no need for the <code>LogHandler</code> to
check if the <code>level</code> is above or below the configured <code><a href="../Protocols/LogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a></code> as <code><a href="../Structs/Logger.html">Logger</a></code> already performed this check and
determined that a message should be logged.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>level</em>
</code>
</td>
<td>
<div>
<p>The log level the message was logged at.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>message</em>
</code>
</td>
<td>
<div>
<p>The message to log. To obtain a <code>String</code> representation call <code>message.description</code>.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>metadata</em>
</code>
</td>
<td>
<div>
<p>The metadata associated to this log message.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>file</em>
</code>
</td>
<td>
<div>
<p>The file the log message was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>function</em>
</code>
</td>
<td>
<div>
<p>The function the log line was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>line</em>
</code>
</td>
<td>
<div>
<p>The line the log message was emitted from.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/LogHandler.swift#L126">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Add, remove, or change the logging metadata.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p><code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.</p>
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">_</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>metadataKey</em>
</code>
</td>
<td>
<div>
<p>The key for the metadata item</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/LogHandler.swift#L138">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the entire metadata storage as a dictionary.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/LogHandler.swift#L144">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the configured log level.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat the log level as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>. It is acceptable to provide some form of global log level override
that means a change in log level on a particular <code>LogHandler</code> might not be reflected in any
<code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/LogHandler.swift#L152">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-224
View File
@@ -1,224 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Structures Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Structures" class="dashAnchor"></a>
<a title="Structures Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Structures Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Structures</h1>
<p>The following structures are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV"></a>
<a name="//apple_ref/swift/Struct/Logger" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV">Logger</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>Logger</code> is the central type in <code>SwiftLog</code>. Its central function is to emit log messages using one of the methods
corresponding to a log level.</p>
<p>The most basic usage of a <code>Logger</code> is</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello World!"</span><span class="p">)</span>
</code></pre>
<a href="Structs/Logger.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Logger</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L28-L39">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging19MultiplexLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/MultiplexLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging19MultiplexLogHandlerV">MultiplexLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A pseudo-<code><a href="Protocols/LogHandler.html">LogHandler</a></code> that can be used to send messages to multiple other <code><a href="Protocols/LogHandler.html">LogHandler</a></code>s.</p>
<p>The first <code><a href="Protocols/LogHandler.html">LogHandler</a></code> passed to the initialisation function of <code>MultiplexLogHandler</code> control the <code>logLevel</code> as
well as the <code>metadata</code> for this <code><a href="Protocols/LogHandler.html">LogHandler</a></code>. Any subsequent <code><a href="Protocols/LogHandler.html">LogHandler</a></code>s used to initialise a
<code>MultiplexLogHandler</code> are merely to emit the log message to another place.</p>
<a href="Structs/MultiplexLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">MultiplexLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L471-L527">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/StreamLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV">StreamLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>StreamLogHandler</code> is a simple implementation of <code><a href="Protocols/LogHandler.html">LogHandler</a></code> for directing
<code><a href="Structs/Logger.html">Logger</a></code> output to either <code>stderr</code> or <code>stdout</code> via the factory methods.</p>
<a href="Structs/StreamLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">StreamLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L576-L639">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,381 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Level Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/Level" class="dashAnchor"></a>
<a title="Level Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
Level Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Level</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Level</span> <span class="p">:</span> <span class="kt">CaseIterable</span></code></pre>
</div>
</div>
<p>The log level.</p>
<p>Log levels are ordered by their severity, with <code>.trace</code> being the least severe and
<code>.critical</code> being the most severe.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5traceyA2EmF"></a>
<a name="//apple_ref/swift/Element/trace" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5traceyA2EmF">trace</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information only when debugging a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">trace</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L332">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5debugyA2EmF"></a>
<a name="//apple_ref/swift/Element/debug" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5debugyA2EmF">debug</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information normally of use only when
debugging a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">debug</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L336">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO4infoyA2EmF"></a>
<a name="//apple_ref/swift/Element/info" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO4infoyA2EmF">info</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for informational messages.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">info</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L339">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO6noticeyA2EmF"></a>
<a name="//apple_ref/swift/Element/notice" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">notice</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for conditions that are not error conditions, but that may require
special handling.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">notice</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L343">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO7warningyA2EmF"></a>
<a name="//apple_ref/swift/Element/warning" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO7warningyA2EmF">warning</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that are not error conditions, but more severe than
<code><a href="../../Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">.notice</a></code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">warning</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L347">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5erroryA2EmF"></a>
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5erroryA2EmF">error</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for error conditions.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">error</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L350">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO8criticalyA2EmF"></a>
<a name="//apple_ref/swift/Element/critical" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO8criticalyA2EmF">critical</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for critical error conditions that usually require immediate
attention.</p>
<p>When a <code>critical</code> message is logged, the logging backend (<code><a href="../../Protocols/LogHandler.html">LogHandler</a></code>) is free to perform
more heavy-weight operations to capture system state (such as capturing stack traces) to facilitate
debugging.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">critical</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L358">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:SL1loiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/&lt;(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SL1loiySbx_xtFZ">&lt;(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L410-L412">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,226 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Message Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/Message" class="dashAnchor"></a>
<a title="Message Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
Message Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>Message</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Message</span><span class="p">:</span> <span class="kt">ExpressibleByStringLiteral</span><span class="p">,</span>
<span class="kt">Equatable</span><span class="p">,</span>
<span class="kt">CustomStringConvertible</span><span class="p">,</span>
<span class="kt">ExpressibleByStringInterpolation</span></code></pre>
</div>
</div>
<p><code>Logger.Message</code> represents a log message&rsquo;s text. It is usually created using string literals.</p>
<p>Example creating a <code>Logger.Message</code>:</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">world</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"world"</span>
<span class="k">let</span> <span class="nv">myLogMessage</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span> <span class="o">=</span> <span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span>
</code></pre>
<p>Most commonly, <code>Logger.Message</code>s appear simply as the parameter to a logging method such as:</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span><span class="p">)</span>
</code></pre>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L456-L458">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L460-L462">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,552 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MetadataValue Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/MetadataValue" class="dashAnchor"></a>
<a title="MetadataValue Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
MetadataValue Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>MetadataValue</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">MetadataValue</span></code></pre>
</div>
</div>
<p>A logging metadata value. <code>Logger.MetadataValue</code> is string, array, and dictionary literal convertible.</p>
<p><code>MetadataValue</code> provides convenient conformances to <code>ExpressibleByStringInterpolation</code>,
<code>ExpressibleByStringLiteral</code>, <code>ExpressibleByArrayLiteral</code>, and <code>ExpressibleByDictionaryLiteral</code> which means
that when constructing <code>MetadataValue</code>s you should default to using Swift&rsquo;s usual literals.</p>
<p>Examples:</p>
<ul>
<li>prefer <code>logger.info(&quot;user logged in&quot;, metadata: [&quot;user-id&quot;: &quot;\(user.id)&quot;])</code> over
<code>..., metadata: [&quot;user-id&quot;: .string(user.id.description)])</code></li>
<li>prefer <code>logger.info(&quot;user selected colours&quot;, metadata: [&quot;colors&quot;: [&quot;\(user.topColor)&quot;, &quot;\(user.secondColor)&quot;]])</code>
over <code>..., metadata: [&quot;colors&quot;: .array([.string(&quot;\(user.topColor)&quot;), .string(&quot;\(user.secondColor)&quot;)])</code></li>
<li>prefer <code>logger.info(&quot;nested info&quot;, metadata: [&quot;nested&quot;: [&quot;fave-numbers&quot;: [&quot;\(1)&quot;, &quot;\(2)&quot;, &quot;\(3)&quot;], &quot;foo&quot;: &quot;bar&quot;]])</code>
over <code>..., metadata: [&quot;nested&quot;: .dictionary([&quot;fave-numbers&quot;: ...])])</code></li>
</ul>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF"></a>
<a name="//apple_ref/swift/Element/string(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF">string(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a <code>String</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByStringInterpolation</code>, and <code>ExpressibleByStringLiteral</code>,
you don&rsquo;t need to type <code>.string(someType.description)</code> you can use the string interpolation <code>&quot;\(someType)&quot;</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">string</span><span class="p">(</span><span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L308">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF"></a>
<a name="//apple_ref/swift/Element/stringConvertible(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF">stringConvertible(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is some <code>CustomStringConvertible</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">stringConvertible</span><span class="p">(</span><span class="kt">CustomStringConvertible</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L311">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/dictionary(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF">dictionary(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a dictionary from <code>String</code> to <code>Logger.MetadataValue</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByDictionaryLiteral</code>, you don&rsquo;t need to type
<code>.dictionary([&quot;foo&quot;: .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;: &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">dictionary</span><span class="p">(</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L317">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/array(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF">array(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is an array of <code>Logger.MetadataValue</code>s.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByArrayLiteral</code>, you don&rsquo;t need to type
<code>.array([.string(&quot;foo&quot;), .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;, &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">array</span><span class="p">([</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">])</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L323">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:SQ2eeoiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/==(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SQ2eeoiySbx_xtFZ">==(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">==</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L420-L433">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L646-L648">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L654-L665">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP3KeyQa"></a>
<a name="//apple_ref/swift/Alias/Key" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP3KeyQa">Key</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Key</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP5ValueQa"></a>
<a name="//apple_ref/swift/Alias/Value" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Value</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt">Value</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc">init(dictionaryLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">dictionaryLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="p">(</span><span class="kt">String</span><span class="p">,</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L678-L680">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP0cD7ElementQa"></a>
<a name="//apple_ref/swift/Alias/ArrayLiteralElement" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP0cD7ElementQa">ArrayLiteralElement</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">ArrayLiteralElement</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(arrayLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc">init(arrayLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">arrayLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L688-L690">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,300 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MultiplexLogHandler Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/MultiplexLogHandler" class="dashAnchor"></a>
<a title="MultiplexLogHandler Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
MultiplexLogHandler Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>MultiplexLogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">MultiplexLogHandler</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<p>A pseudo-<code><a href="../Protocols/LogHandler.html">LogHandler</a></code> that can be used to send messages to multiple other <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s.</p>
<p>The first <code><a href="../Protocols/LogHandler.html">LogHandler</a></code> passed to the initialisation function of <code>MultiplexLogHandler</code> control the <code>logLevel</code> as
well as the <code>metadata</code> for this <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>. Any subsequent <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s used to initialise a
<code>MultiplexLogHandler</code> are merely to emit the log message to another place.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc"></a>
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc">init(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Create a <code>MultiplexLogHandler</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">handlers</span><span class="p">:</span> <span class="p">[</span><span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span><span class="p">])</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>handlers</em>
</code>
</td>
<td>
<div>
<p>An array of <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s, each of which will receive the log messages sent to this <code><a href="../Structs/Logger.html">Logger</a></code>.
The array must not be empty.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L479-L482">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L484-L493">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span>
<span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span>
<span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L495-L502">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L504-L511">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L513-L520">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,307 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>StreamLogHandler Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/StreamLogHandler" class="dashAnchor"></a>
<a title="StreamLogHandler Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
StreamLogHandler Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1>StreamLogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">StreamLogHandler</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<p><code>StreamLogHandler</code> is a simple implementation of <code><a href="../Protocols/LogHandler.html">LogHandler</a></code> for directing
<code><a href="../Structs/Logger.html">Logger</a></code> output to either <code>stderr</code> or <code>stdout</code> via the factory methods.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ"></a>
<a name="//apple_ref/swift/Method/standardOutput(label:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ">standardOutput(label:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stdout</code></p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">standardOutput</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">StreamLogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L578-L580">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ"></a>
<a name="//apple_ref/swift/Method/standardError(label:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ">standardError(label:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stderr</code></p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">standardError</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">StreamLogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L583-L585">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L152">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L592-L596">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L598-L605">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span>
<span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span>
<span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.1.1/Sources/Logging/Logging.swift#L612-L622">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-28
View File
@@ -1,28 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="136" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="a">
<rect width="136" height="20" rx="3" fill="#fff"/>
</clipPath>
<g clip-path="url(#a)">
<path fill="#555" d="M0 0h93v20H0z"/>
<path fill="#4c1" d="M93 0h43v20H93z"/>
<path fill="url(#b)" d="M0 0h136v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
<text x="475" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="830">
documentation
</text>
<text x="475" y="140" transform="scale(.1)" textLength="830">
documentation
</text>
<text x="1135" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">
100%
</text>
<text x="1135" y="140" transform="scale(.1)" textLength="330">
100%
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

-200
View File
@@ -1,200 +0,0 @@
/* Credit to https://gist.github.com/wataru420/2048287 */
.highlight {
/* Comment */
/* Error */
/* Keyword */
/* Operator */
/* Comment.Multiline */
/* Comment.Preproc */
/* Comment.Single */
/* Comment.Special */
/* Generic.Deleted */
/* Generic.Deleted.Specific */
/* Generic.Emph */
/* Generic.Error */
/* Generic.Heading */
/* Generic.Inserted */
/* Generic.Inserted.Specific */
/* Generic.Output */
/* Generic.Prompt */
/* Generic.Strong */
/* Generic.Subheading */
/* Generic.Traceback */
/* Keyword.Constant */
/* Keyword.Declaration */
/* Keyword.Pseudo */
/* Keyword.Reserved */
/* Keyword.Type */
/* Literal.Number */
/* Literal.String */
/* Name.Attribute */
/* Name.Builtin */
/* Name.Class */
/* Name.Constant */
/* Name.Entity */
/* Name.Exception */
/* Name.Function */
/* Name.Namespace */
/* Name.Tag */
/* Name.Variable */
/* Operator.Word */
/* Text.Whitespace */
/* Literal.Number.Float */
/* Literal.Number.Hex */
/* Literal.Number.Integer */
/* Literal.Number.Oct */
/* Literal.String.Backtick */
/* Literal.String.Char */
/* Literal.String.Doc */
/* Literal.String.Double */
/* Literal.String.Escape */
/* Literal.String.Heredoc */
/* Literal.String.Interpol */
/* Literal.String.Other */
/* Literal.String.Regex */
/* Literal.String.Single */
/* Literal.String.Symbol */
/* Name.Builtin.Pseudo */
/* Name.Variable.Class */
/* Name.Variable.Global */
/* Name.Variable.Instance */
/* Literal.Number.Integer.Long */ }
.highlight .c {
color: #999988;
font-style: italic; }
.highlight .err {
color: #a61717;
background-color: #e3d2d2; }
.highlight .k {
color: #000000;
font-weight: bold; }
.highlight .o {
color: #000000;
font-weight: bold; }
.highlight .cm {
color: #999988;
font-style: italic; }
.highlight .cp {
color: #999999;
font-weight: bold; }
.highlight .c1 {
color: #999988;
font-style: italic; }
.highlight .cs {
color: #999999;
font-weight: bold;
font-style: italic; }
.highlight .gd {
color: #000000;
background-color: #ffdddd; }
.highlight .gd .x {
color: #000000;
background-color: #ffaaaa; }
.highlight .ge {
color: #000000;
font-style: italic; }
.highlight .gr {
color: #aa0000; }
.highlight .gh {
color: #999999; }
.highlight .gi {
color: #000000;
background-color: #ddffdd; }
.highlight .gi .x {
color: #000000;
background-color: #aaffaa; }
.highlight .go {
color: #888888; }
.highlight .gp {
color: #555555; }
.highlight .gs {
font-weight: bold; }
.highlight .gu {
color: #aaaaaa; }
.highlight .gt {
color: #aa0000; }
.highlight .kc {
color: #000000;
font-weight: bold; }
.highlight .kd {
color: #000000;
font-weight: bold; }
.highlight .kp {
color: #000000;
font-weight: bold; }
.highlight .kr {
color: #000000;
font-weight: bold; }
.highlight .kt {
color: #445588; }
.highlight .m {
color: #009999; }
.highlight .s {
color: #d14; }
.highlight .na {
color: #008080; }
.highlight .nb {
color: #0086B3; }
.highlight .nc {
color: #445588;
font-weight: bold; }
.highlight .no {
color: #008080; }
.highlight .ni {
color: #800080; }
.highlight .ne {
color: #990000;
font-weight: bold; }
.highlight .nf {
color: #990000; }
.highlight .nn {
color: #555555; }
.highlight .nt {
color: #000080; }
.highlight .nv {
color: #008080; }
.highlight .ow {
color: #000000;
font-weight: bold; }
.highlight .w {
color: #bbbbbb; }
.highlight .mf {
color: #009999; }
.highlight .mh {
color: #009999; }
.highlight .mi {
color: #009999; }
.highlight .mo {
color: #009999; }
.highlight .sb {
color: #d14; }
.highlight .sc {
color: #d14; }
.highlight .sd {
color: #d14; }
.highlight .s2 {
color: #d14; }
.highlight .se {
color: #d14; }
.highlight .sh {
color: #d14; }
.highlight .si {
color: #d14; }
.highlight .sx {
color: #d14; }
.highlight .sr {
color: #009926; }
.highlight .s1 {
color: #d14; }
.highlight .ss {
color: #990073; }
.highlight .bp {
color: #999999; }
.highlight .vc {
color: #008080; }
.highlight .vg {
color: #008080; }
.highlight .vi {
color: #008080; }
.highlight .il {
color: #009999; }
-372
View File
@@ -1,372 +0,0 @@
*, *:before, *:after {
box-sizing: inherit; }
body {
margin: 0;
background: #fff;
color: #333;
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
letter-spacing: .2px;
-webkit-font-smoothing: antialiased;
box-sizing: border-box; }
h1 {
font-size: 2rem;
font-weight: 700;
margin: 1.275em 0 0.6em; }
h2 {
font-size: 1.75rem;
font-weight: 700;
margin: 1.275em 0 0.3em; }
h3 {
font-size: 1.5rem;
font-weight: 700;
margin: 1em 0 0.3em; }
h4 {
font-size: 1.25rem;
font-weight: 700;
margin: 1.275em 0 0.85em; }
h5 {
font-size: 1rem;
font-weight: 700;
margin: 1.275em 0 0.85em; }
h6 {
font-size: 1rem;
font-weight: 700;
margin: 1.275em 0 0.85em;
color: #777; }
p {
margin: 0 0 1em; }
ul, ol {
padding: 0 0 0 2em;
margin: 0 0 0.85em; }
blockquote {
margin: 0 0 0.85em;
padding: 0 15px;
color: #858585;
border-left: 4px solid #e5e5e5; }
img {
max-width: 100%; }
a {
color: #4183c4;
text-decoration: none; }
a:hover, a:focus {
outline: 0;
text-decoration: underline; }
a.discouraged {
text-decoration: line-through; }
a.discouraged:hover, a.discouraged:focus {
text-decoration: underline line-through; }
table {
background: #fff;
width: 100%;
border-collapse: collapse;
border-spacing: 0;
overflow: auto;
margin: 0 0 0.85em; }
tr:nth-child(2n) {
background-color: #fbfbfb; }
th, td {
padding: 6px 13px;
border: 1px solid #ddd; }
pre {
margin: 0 0 1.275em;
padding: .85em 1em;
overflow: auto;
background: #f7f7f7;
font-size: .85em;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
code {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
p > code, li > code {
background: #f7f7f7;
padding: .2em; }
p > code:before, p > code:after, li > code:before, li > code:after {
letter-spacing: -.2em;
content: "\00a0"; }
pre code {
padding: 0;
white-space: pre; }
.content-wrapper {
display: flex;
flex-direction: column; }
@media (min-width: 768px) {
.content-wrapper {
flex-direction: row; } }
.header {
display: flex;
padding: 8px;
font-size: 0.875em;
background: #444;
color: #999; }
.header-col {
margin: 0;
padding: 0 8px; }
.header-col--primary {
flex: 1; }
.header-link {
color: #fff; }
.header-icon {
padding-right: 6px;
vertical-align: -4px;
height: 16px; }
.breadcrumbs {
font-size: 0.875em;
padding: 8px 16px;
margin: 0;
background: #fbfbfb;
border-bottom: 1px solid #ddd; }
.carat {
height: 10px;
margin: 0 5px; }
.navigation {
order: 2; }
@media (min-width: 768px) {
.navigation {
order: 1;
width: 25%;
max-width: 300px;
padding-bottom: 64px;
overflow: hidden;
word-wrap: normal;
background: #fbfbfb;
border-right: 1px solid #ddd; } }
.nav-groups {
list-style-type: none;
padding-left: 0; }
.nav-group-name {
border-bottom: 1px solid #ddd;
padding: 8px 0 8px 16px; }
.nav-group-name-link {
color: #333; }
.nav-group-tasks {
margin: 8px 0;
padding: 0 0 0 8px; }
.nav-group-task {
font-size: 1em;
list-style-type: none;
white-space: nowrap; }
.nav-group-task-link {
color: #808080; }
.main-content {
order: 1; }
@media (min-width: 768px) {
.main-content {
order: 2;
flex: 1;
padding-bottom: 60px; } }
.section {
padding: 0 32px;
border-bottom: 1px solid #ddd; }
.section-content {
max-width: 834px;
margin: 0 auto;
padding: 16px 0; }
.section-name {
color: #666;
display: block; }
.declaration .highlight {
overflow-x: initial;
padding: 8px 0;
margin: 0;
background-color: transparent;
border: none; }
.task-group-section {
border-top: 1px solid #ddd; }
.task-group {
padding-top: 0px; }
.task-name-container a[name]:before {
content: "";
display: block; }
.item-container {
padding: 0; }
.item {
padding-top: 8px;
width: 100%;
list-style-type: none; }
.item a[name]:before {
content: "";
display: block; }
.item .token, .item .direct-link {
padding-left: 3px;
margin-left: 0px;
font-size: 1rem; }
.item .declaration-note {
font-size: .85em;
color: #808080;
font-style: italic; }
.pointer-container {
border-bottom: 1px solid #ddd;
left: -23px;
padding-bottom: 13px;
position: relative;
width: 110%; }
.pointer {
left: 21px;
top: 7px;
display: block;
position: absolute;
width: 12px;
height: 12px;
border-left: 1px solid #ddd;
border-top: 1px solid #ddd;
background: #fff;
transform: rotate(45deg); }
.height-container {
display: none;
position: relative;
width: 100%;
overflow: hidden; }
.height-container .section {
background: #fff;
border: 1px solid #ddd;
border-top-width: 0;
padding-top: 10px;
padding-bottom: 5px;
padding: 8px 16px; }
.aside, .language {
padding: 6px 12px;
margin: 12px 0;
border-left: 5px solid #dddddd;
overflow-y: hidden; }
.aside .aside-title, .language .aside-title {
font-size: 9px;
letter-spacing: 2px;
text-transform: uppercase;
padding-bottom: 0;
margin: 0;
color: #aaa;
-webkit-user-select: none; }
.aside p:last-child, .language p:last-child {
margin-bottom: 0; }
.language {
border-left: 5px solid #cde9f4; }
.language .aside-title {
color: #4183c4; }
.aside-warning, .aside-deprecated, .aside-unavailable {
border-left: 5px solid #ff6666; }
.aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title {
color: #ff0000; }
.graybox {
border-collapse: collapse;
width: 100%; }
.graybox p {
margin: 0;
word-break: break-word;
min-width: 50px; }
.graybox td {
border: 1px solid #ddd;
padding: 5px 25px 5px 10px;
vertical-align: middle; }
.graybox tr td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px; }
.slightly-smaller {
font-size: 0.9em; }
.footer {
padding: 8px 16px;
background: #444;
color: #ddd;
font-size: 0.8em; }
.footer p {
margin: 8px 0; }
.footer a {
color: #fff; }
html.dash .header, html.dash .breadcrumbs, html.dash .navigation {
display: none; }
html.dash .height-container {
display: block; }
form[role=search] input {
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 24px;
padding: 0 10px;
margin: 0;
border: none;
border-radius: 1em; }
.loading form[role=search] input {
background: white url(../img/spinner.gif) center right 4px no-repeat; }
form[role=search] .tt-menu {
margin: 0;
min-width: 300px;
background: #fbfbfb;
color: #333;
border: 1px solid #ddd; }
form[role=search] .tt-highlight {
font-weight: bold; }
form[role=search] .tt-suggestion {
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 0 8px; }
form[role=search] .tt-suggestion span {
display: table-cell;
white-space: nowrap; }
form[role=search] .tt-suggestion .doc-parent-name {
width: 100%;
text-align: right;
font-weight: normal;
font-size: 0.9em;
padding-left: 16px; }
form[role=search] .tt-suggestion:hover,
form[role=search] .tt-suggestion.tt-cursor {
cursor: pointer;
background-color: #4183c4;
color: #fff; }
form[role=search] .tt-suggestion:hover .doc-parent-name,
form[role=search] .tt-suggestion.tt-cursor .doc-parent-name {
color: #fff; }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

-118
View File
@@ -1,118 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Logging Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a title="Logging Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Logging Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content">
<h1 id='swiftlog-docs' class='heading'>SwiftLog Docs</h1>
<p>SwiftLog is a Swift logging API package.</p>
<p>To get started with SwiftLog, <a href="../Logging/index.html"><code>import Logging</code></a>. The
most important type is <a href="https://apple.github.io/swift-log/docs/current/Logging/Structs/Logger.html"><code><a href="Structs/Logger.html">Logger</a></code></a>
which you can use to emit log messages.</p>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2019-09-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-59
View File
@@ -1,59 +0,0 @@
window.jazzy = {'docset': false}
if (typeof window.dash != 'undefined') {
document.documentElement.className += ' dash'
window.jazzy.docset = true
}
if (navigator.userAgent.match(/xcode/i)) {
document.documentElement.className += ' xcode'
window.jazzy.docset = true
}
function toggleItem($link, $content) {
var animationDuration = 300;
$link.toggleClass('token-open');
$content.slideToggle(animationDuration);
}
function itemLinkToContent($link) {
return $link.parent().parent().next();
}
// On doc load + hash-change, open any targetted item
function openCurrentItemIfClosed() {
if (window.jazzy.docset) {
return;
}
var $link = $(`.token[href="${location.hash}"]`);
$content = itemLinkToContent($link);
if ($content.is(':hidden')) {
toggleItem($link, $content);
}
}
$(openCurrentItemIfClosed);
$(window).on('hashchange', openCurrentItemIfClosed);
// On item link ('token') click, toggle its discussion
$('.token').on('click', function(event) {
if (window.jazzy.docset) {
return;
}
var $link = $(this);
toggleItem($link, itemLinkToContent($link));
// Keeps the document from jumping to the hash.
var href = $link.attr('href');
if (history.pushState) {
history.pushState({}, '', href);
} else {
location.hash = href;
}
event.preventDefault();
});
// Clicks on links to the current, closed, item need to open the item
$("a:not('.token')").on('click', function() {
if (location == this.href) {
openCurrentItemIfClosed();
}
});
-70
View File
@@ -1,70 +0,0 @@
$(function(){
var $typeahead = $('[data-typeahead]');
var $form = $typeahead.parents('form');
var searchURL = $form.attr('action');
function displayTemplate(result) {
return result.name;
}
function suggestionTemplate(result) {
var t = '<div class="list-group-item clearfix">';
t += '<span class="doc-name">' + result.name + '</span>';
if (result.parent_name) {
t += '<span class="doc-parent-name label">' + result.parent_name + '</span>';
}
t += '</div>';
return t;
}
$typeahead.one('focus', function() {
$form.addClass('loading');
$.getJSON(searchURL).then(function(searchData) {
const searchIndex = lunr(function() {
this.ref('url');
this.field('name');
this.field('abstract');
for (const [url, doc] of Object.entries(searchData)) {
this.add({url: url, name: doc.name, abstract: doc.abstract});
}
});
$typeahead.typeahead(
{
highlight: true,
minLength: 3,
autoselect: true
},
{
limit: 10,
display: displayTemplate,
templates: { suggestion: suggestionTemplate },
source: function(query, sync) {
const lcSearch = query.toLowerCase();
const results = searchIndex.query(function(q) {
q.term(lcSearch, { boost: 100 });
q.term(lcSearch, {
boost: 10,
wildcard: lunr.Query.wildcard.TRAILING
});
}).map(function(result) {
var doc = searchData[result.ref];
doc.url = result.ref;
return doc;
});
sync(results);
}
}
);
$form.removeClass('loading');
$typeahead.trigger('focus');
});
});
var baseURL = searchURL.slice(0, -"search.json".length);
$typeahead.on('typeahead:select', function(e, result) {
window.location = baseURL + result.url;
});
});
-2
View File
@@ -1,2 +0,0 @@
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)Line truncated
-1
View File
@@ -1 +0,0 @@
!function(){var t,l,c,e,r,h,d,f,p,y,m,g,x,v,w,Q,k,S,E,L,b,P,T,O,I,i,n,s,z=function(e){var t=new z.Builder;return t.pipeline.add(z.trimmer,z.stopWordFilter,z.stemmer),t.searchPipeline.add(z.stemmer),e.call(t,t),t.build()};z.version="2.3.5",z.utils={},z.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),z.utils.asString=function(e){return null==e?"":e.toString()},z.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],s=e[n];if(Array.isArray(s))t[n]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[n]=s}}return t},z.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},z.FieldRef.joiner="/",z.FieldRef.fromString=function(e){var t=e.indexOf(z.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),i=e.slice(t+1);return new z.FieldRef(i,r,e)},z.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+z.FieldRef.joiner+this.docRef),this._stringValue},z.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},z.Set.complete={intersect:function(e){return e},union:function(e){return e},contains:function(){return!0}},z.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},z.Set.prototype.contains=function(e){return!!this.elements[e]},z.Set.prototype.intersect=function(e){var t,r,i,n=[];if(e===z.Set.complete)return this;if(e===z.Set.empty)return e;r=this.length<e.length?(t=this,e):(t=e,this),i=Object.keys(t.elements);for(var s=0;s<i.length;s++){var o=i[s];o in r.elements&&n.push(o)}return new z.Set(n)},z.Set.prototype.union=function(e){return e===z.Set.complete?z.Set.complete:e===z.Set.empty?this:new z.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},z.idf=function(e,t){var r=0;for(var i in e)"_index"!=i&&(r+=Object.keys(e[i]).length);var n=(t-r+.5)/(r+.5);return Math.log(1+Math.abs(n))},z.Token=function(e,t){this.str=e||"",this.metadata=t||{}},z.Token.prototype.toString=function(){return this.str},z.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},z.Token.prototype.clone=function(e){return e=e||function(e){return e},new z.Token(e(this.str,this.metadata),this.metadata)},z.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return new z.Token(z.utils.asString(e).toLowerCase(),z.utils.clone(t))});for(var r=e.toString().trim().toLowerCase(),i=r.length,n=[],s=0,o=0;s<=i;s++){var a=s-o;if(r.charAt(s).match(z.tokenizer.separator)||s==i){if(0<a){var u=z.utils.clone(t)||{};u.position=[o,a],u.index=n.length,n.push(new z.Token(r.slice(o,s),u))}o=s+1}}return n},z.tokenizer.separator=/[\s\-]+/,z.Pipeline=function(){this._stack=[]},z.Pipeline.registeredFunctions=Object.create(null),z.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&z.utils.warn("Overwriting existing registered function: "+t),e.label=t,z.Pipeline.registeredFunctions[e.label]=e},z.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||z.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},z.Pipeline.load=function(e){var r=new z.Pipeline;return e.forEach(function(e){var t=z.Pipeline.registeredFunctions[e];if(!t)throw new Error("Cannot load unregistered function: "+e);r.add(t)}),r},z.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){z.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},z.Pipeline.prototype.after=function(e,t){z.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},z.Pipeline.prototype.before=function(e,t){z.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,t)},z.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},z.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var i=this._stack[r],n=[],s=0;s<e.length;s++){var o=i(e[s],s,e);if(void 0!==o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)n.push(o[a]);else n.push(o)}e=n}return e},z.Pipeline.prototype.runString=function(e,t){var r=new z.Token(e,t);return this.run([r]).map(function(e){return e.toString()})},z.Pipeline.prototype.reset=function(){this._stack=[]},z.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return z.Pipeline.warnIfFunctionNotRegistered(e),e.label})},z.Vector=function(e){this._magnitude=0,this.elements=e||[]},z.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;Line truncated
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1 +0,0 @@
{"Structs/StreamLogHandler.html#/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ":{"name":"standardOutput(label:)","abstract":"<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stdout</code></p>","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ":{"name":"standardError(label:)","abstract":"<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stderr</code></p>","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp":{"name":"logLevel","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp":{"name":"metadata","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip":{"name":"subscript(metadataKey:)","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF":{"name":"log(level:message:metadata:file:function:line:)","parent_name":"StreamLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc":{"name":"init(_:)","abstract":"<p>Create a <code>MultiplexLogHandler</code>.</p>","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp":{"name":"logLevel","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF":{"name":"log(level:message:metadata:file:function:line:)","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp":{"name":"metadata","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip":{"name":"subscript(metadataKey:)","parent_name":"MultiplexLogHandler"},"Structs/Logger/Message.html#/s:s26ExpressibleByStringLiteralP0cD4TypeQa":{"name":"StringLiteralType","parent_name":"Message"},"Structs/Logger/Message.html#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc":{"name":"init(stringLiteral:)","parent_name":"Message"},"Structs/Logger/Message.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"Message"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5traceyA2EmF":{"name":"trace","abstract":"<p>Appropriate for messages that contain information only when debugging a program.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5debugyA2EmF":{"name":"debug","abstract":"<p>Appropriate for messages that contain information normally of use only when","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO4infoyA2EmF":{"name":"info","abstract":"<p>Appropriate for informational messages.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO6noticeyA2EmF":{"name":"notice","abstract":"<p>Appropriate for conditions that are not error conditions, but that may require","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO7warningyA2EmF":{"name":"warning","abstract":"<p>Appropriate for messages that are not error conditions, but more severe than","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5erroryA2EmF":{"name":"error","abstract":"<p>Appropriate for error conditions.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO8criticalyA2EmF":{"name":"critical","abstract":"<p>Appropriate for critical error conditions that usually require immediate","parent_name":"Level"},"Structs/Logger/Level.html#/s:SL1loiySbx_xtFZ":{"name":"<(_:_:)","parent_name":"Level"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF":{"name":"string(_:)","abstract":"<p>A metadata value which is a <code>String</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF":{"name":"stringConvertible(_:)","abstract":"<p>A metadata value which is some <code>CustomStringConvertible</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF":{"name":"dictionary(_:)","abstract":"<p>A metadata value which is a dictionary from <code>String</code> to <code>Logger.MetadataValue</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF":{"name":"array(_:)","abstract":"<p>A metadata value which is an array of <code>Logger.MetadataValue</code>sLine truncated
-6
View File
@@ -1,6 +0,0 @@
{
"warnings": [
],
"source_directory": "/code"
}
-160
View File
@@ -1,160 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Enumerations Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Enumerations" class="dashAnchor"></a>
<a title="Enumerations Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Enumerations Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Enumerations</h1>
<p>The following enumerations are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO"></a>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO">LoggingSystem</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
<a href="Enums/LoggingSystem.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L254-L279">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-186
View File
@@ -1,186 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LoggingSystem Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a title="LoggingSystem Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
LoggingSystem Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>LoggingSystem</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="../Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ"></a>
<a name="//apple_ref/swift/Method/bootstrap(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ">bootstrap(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>bootstrap</code> is a one-time configuration function which globally selects the desired logging backend
implementation. <code>bootstrap</code> can be called at maximum once in any given program, calling it more than once will
lead to undefined behaviour, most likely a crash.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">bootstrap</span><span class="p">(</span><span class="n">_</span> <span class="nv">factory</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>factory</em>
</code>
</td>
<td>
<div>
<p>A closure that given a <code><a href="../Structs/Logger.html">Logger</a></code> identifier, produces an instance of the <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L265-L271">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-251
View File
@@ -1,251 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Protocols Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Protocols" class="dashAnchor"></a>
<a title="Protocols Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Protocols Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Protocols</h1>
<p>The following protocols are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP"></a>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP">LogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">Lock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span>
<span class="p">}</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="Structs/Logger.html">Logger</a></code> variable.</p>
<a href="Protocols/LogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/LogHandler.swift#L114-L153">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,466 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LogHandler Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a title="LogHandler Protocol Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
LogHandler Protocol Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>LogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="../Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="../Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="../Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="../Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="../Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">Lock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span>
<span class="p">}</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="n">withLock</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="../Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="../Structs/Logger.html">Logger</a></code> variable.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>This method is called when a <code>LogHandler</code> must emit a log message. There is no need for the <code>LogHandler</code> to
check if the <code>level</code> is above or below the configured <code><a href="../Protocols/LogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a></code> as <code><a href="../Structs/Logger.html">Logger</a></code> already performed this check and
determined that a message should be logged.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>level</em>
</code>
</td>
<td>
<div>
<p>The log level the message was logged at.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>message</em>
</code>
</td>
<td>
<div>
<p>The message to log. To obtain a <code>String</code> representation call <code>message.description</code>.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>metadata</em>
</code>
</td>
<td>
<div>
<p>The metadata associated to this log message.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>file</em>
</code>
</td>
<td>
<div>
<p>The file the log message was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>function</em>
</code>
</td>
<td>
<div>
<p>The function the log line was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>line</em>
</code>
</td>
<td>
<div>
<p>The line the log message was emitted from.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/LogHandler.swift#L126">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Add, remove, or change the logging metadata.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p><code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.</p>
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">_</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>metadataKey</em>
</code>
</td>
<td>
<div>
<p>The key for the metadata item</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/LogHandler.swift#L138">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the entire metadata storage as a dictionary.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/LogHandler.swift#L144">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the configured log level.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat the log level as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>. It is acceptable to provide some form of global log level override
that means a change in log level on a particular <code>LogHandler</code> might not be reflected in any
<code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/LogHandler.swift#L152">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-230
View File
@@ -1,230 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Structures Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Structures" class="dashAnchor"></a>
<a title="Structures Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Structures Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Structures</h1>
<p>The following structures are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV"></a>
<a name="//apple_ref/swift/Struct/Logger" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV">Logger</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>Logger</code> is the central type in <code>SwiftLog</code>. Its central function is to emit log messages using one of the methods
corresponding to a log level.</p>
<p>The most basic usage of a <code>Logger</code> is</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello World!"</span><span class="p">)</span>
</code></pre>
<a href="Structs/Logger.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Logger</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L30-L41">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging19MultiplexLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/MultiplexLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging19MultiplexLogHandlerV">MultiplexLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A pseudo-<code><a href="Protocols/LogHandler.html">LogHandler</a></code> that can be used to send messages to multiple other <code><a href="Protocols/LogHandler.html">LogHandler</a></code>s.</p>
<p>The first <code><a href="Protocols/LogHandler.html">LogHandler</a></code> passed to the initialisation function of <code>MultiplexLogHandler</code> control the <code>logLevel</code> as
well as the <code>metadata</code> for this <code><a href="Protocols/LogHandler.html">LogHandler</a></code>. Any subsequent <code><a href="Protocols/LogHandler.html">LogHandler</a></code>s used to initialise a
<code>MultiplexLogHandler</code> are merely to emit the log message to another place.</p>
<a href="Structs/MultiplexLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">MultiplexLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L466-L522">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/StreamLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV">StreamLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>StreamLogHandler</code> is a simple implementation of <code><a href="Protocols/LogHandler.html">LogHandler</a></code> for directing
<code><a href="Structs/Logger.html">Logger</a></code> output to either <code>stderr</code> or <code>stdout</code> via the factory methods.</p>
<a href="Structs/StreamLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">StreamLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L582-L647">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,384 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Level Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/Level" class="dashAnchor"></a>
<a title="Level Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
Level Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Level</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Level</span> <span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="kt">Codable</span><span class="p">,</span> <span class="kt">CaseIterable</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">:</span> <span class="kt">Comparable</span></code></pre>
</div>
</div>
<p>The log level.</p>
<p>Log levels are ordered by their severity, with <code>.trace</code> being the least severe and
<code>.critical</code> being the most severe.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5traceyA2EmF"></a>
<a name="//apple_ref/swift/Element/trace" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5traceyA2EmF">trace</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information only when debugging a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">trace</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L327">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5debugyA2EmF"></a>
<a name="//apple_ref/swift/Element/debug" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5debugyA2EmF">debug</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information normally of use only when
debugging a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">debug</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L331">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO4infoyA2EmF"></a>
<a name="//apple_ref/swift/Element/info" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO4infoyA2EmF">info</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for informational messages.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">info</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L334">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO6noticeyA2EmF"></a>
<a name="//apple_ref/swift/Element/notice" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">notice</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for conditions that are not error conditions, but that may require
special handling.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">notice</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L338">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO7warningyA2EmF"></a>
<a name="//apple_ref/swift/Element/warning" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO7warningyA2EmF">warning</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that are not error conditions, but more severe than
<code><a href="../../Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">.notice</a></code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">warning</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L342">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5erroryA2EmF"></a>
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5erroryA2EmF">error</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for error conditions.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">error</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L345">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO8criticalyA2EmF"></a>
<a name="//apple_ref/swift/Element/critical" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO8criticalyA2EmF">critical</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for critical error conditions that usually require immediate
attention.</p>
<p>When a <code>critical</code> message is logged, the logging backend (<code><a href="../../Protocols/LogHandler.html">LogHandler</a></code>) is free to perform
more heavy-weight operations to capture system state (such as capturing stack traces) to facilitate
debugging.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">critical</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L353">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:SL1loiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/&lt;(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SL1loiySbx_xtFZ">&lt;(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L405-L407">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,232 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Message Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/Message" class="dashAnchor"></a>
<a title="Message Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
Message Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Message</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Message</span><span class="p">:</span> <span class="kt">ExpressibleByStringLiteral</span><span class="p">,</span>
<span class="kt">Equatable</span><span class="p">,</span>
<span class="kt">CustomStringConvertible</span><span class="p">,</span>
<span class="kt">ExpressibleByStringInterpolation</span></code></pre>
</div>
</div>
<p><code>Logger.Message</code> represents a log message&rsquo;s text. It is usually created using string literals.</p>
<p>Example creating a <code>Logger.Message</code>:</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">world</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"world"</span>
<span class="k">let</span> <span class="nv">myLogMessage</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span> <span class="o">=</span> <span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span>
</code></pre>
<p>Most commonly, <code>Logger.Message</code>s appear simply as the parameter to a logging method such as:</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span><span class="p">)</span>
</code></pre>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L451-L453">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L455-L457">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,544 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MetadataValue Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/MetadataValue" class="dashAnchor"></a>
<a title="MetadataValue Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" />
MetadataValue Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>MetadataValue</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">MetadataValue</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">Equatable</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByStringLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">CustomStringConvertible</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByStringInterpolation</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByDictionaryLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByArrayLiteral</span></code></pre>
</div>
</div>
<p>A logging metadata value. <code>Logger.MetadataValue</code> is string, array, and dictionary literal convertible.</p>
<p><code>MetadataValue</code> provides convenient conformances to <code>ExpressibleByStringInterpolation</code>,
<code>ExpressibleByStringLiteral</code>, <code>ExpressibleByArrayLiteral</code>, and <code>ExpressibleByDictionaryLiteral</code> which means
that when constructing <code>MetadataValue</code>s you should default to using Swift&rsquo;s usual literals.</p>
<p>Examples:</p>
<ul>
<li>prefer <code>logger.info(&quot;user logged in&quot;, metadata: [&quot;user-id&quot;: &quot;\(user.id)&quot;])</code> over
<code>..., metadata: [&quot;user-id&quot;: .string(user.id.description)])</code></li>
<li>prefer <code>logger.info(&quot;user selected colours&quot;, metadata: [&quot;colors&quot;: [&quot;\(user.topColor)&quot;, &quot;\(user.secondColor)&quot;]])</code>
over <code>..., metadata: [&quot;colors&quot;: .array([.string(&quot;\(user.topColor)&quot;), .string(&quot;\(user.secondColor)&quot;)])</code></li>
<li>prefer <code>logger.info(&quot;nested info&quot;, metadata: [&quot;nested&quot;: [&quot;fave-numbers&quot;: [&quot;\(1)&quot;, &quot;\(2)&quot;, &quot;\(3)&quot;], &quot;foo&quot;: &quot;bar&quot;]])</code>
over <code>..., metadata: [&quot;nested&quot;: .dictionary([&quot;fave-numbers&quot;: ...])])</code></li>
</ul>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF"></a>
<a name="//apple_ref/swift/Element/string(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF">string(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a <code>String</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByStringInterpolation</code>, and <code>ExpressibleByStringLiteral</code>,
you don&rsquo;t need to type <code>.string(someType.description)</code> you can use the string interpolation <code>&quot;\(someType)&quot;</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">string</span><span class="p">(</span><span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L303">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF"></a>
<a name="//apple_ref/swift/Element/stringConvertible(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF">stringConvertible(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is some <code>CustomStringConvertible</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">stringConvertible</span><span class="p">(</span><span class="kt">CustomStringConvertible</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L306">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/dictionary(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF">dictionary(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a dictionary from <code>String</code> to <code>Logger.MetadataValue</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByDictionaryLiteral</code>, you don&rsquo;t need to type
<code>.dictionary([&quot;foo&quot;: .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;: &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">dictionary</span><span class="p">(</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L312">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/array(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF">array(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is an array of <code>Logger.MetadataValue</code>s.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByArrayLiteral</code>, you don&rsquo;t need to type
<code>.array([.string(&quot;foo&quot;), .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;, &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">array</span><span class="p">([</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">])</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L318">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:SQ2eeoiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/==(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SQ2eeoiySbx_xtFZ">==(_:_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">==</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L415-L428">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L654-L656">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L662-L673">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP3KeyQa"></a>
<a name="//apple_ref/swift/Alias/Key" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP3KeyQa">Key</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Key</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP5ValueQa"></a>
<a name="//apple_ref/swift/Alias/Value" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Value</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt">Value</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc">init(dictionaryLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">dictionaryLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="p">(</span><span class="kt">String</span><span class="p">,</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L686-L688">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP0cD7ElementQa"></a>
<a name="//apple_ref/swift/Alias/ArrayLiteralElement" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP0cD7ElementQa">ArrayLiteralElement</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">ArrayLiteralElement</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(arrayLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc">init(arrayLiteral:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">arrayLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L696-L698">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,306 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MultiplexLogHandler Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/MultiplexLogHandler" class="dashAnchor"></a>
<a title="MultiplexLogHandler Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
MultiplexLogHandler Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>MultiplexLogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">MultiplexLogHandler</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<p>A pseudo-<code><a href="../Protocols/LogHandler.html">LogHandler</a></code> that can be used to send messages to multiple other <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s.</p>
<p>The first <code><a href="../Protocols/LogHandler.html">LogHandler</a></code> passed to the initialisation function of <code>MultiplexLogHandler</code> control the <code>logLevel</code> as
well as the <code>metadata</code> for this <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>. Any subsequent <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s used to initialise a
<code>MultiplexLogHandler</code> are merely to emit the log message to another place.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc"></a>
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc">init(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Create a <code>MultiplexLogHandler</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">handlers</span><span class="p">:</span> <span class="p">[</span><span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span><span class="p">])</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>handlers</em>
</code>
</td>
<td>
<div>
<p>An array of <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>s, each of which will receive the log messages sent to this <code><a href="../Structs/Logger.html">Logger</a></code>.
The array must not be empty.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L474-L477">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L479-L488">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span>
<span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span>
<span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L490-L497">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L499-L506">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L508-L515">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
@@ -1,313 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>StreamLogHandler Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/StreamLogHandler" class="dashAnchor"></a>
<a title="StreamLogHandler Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="../img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" />
StreamLogHandler Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>StreamLogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">StreamLogHandler</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<p><code>StreamLogHandler</code> is a simple implementation of <code><a href="../Protocols/LogHandler.html">LogHandler</a></code> for directing
<code><a href="../Structs/Logger.html">Logger</a></code> output to either <code>stderr</code> or <code>stdout</code> via the factory methods.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ"></a>
<a name="//apple_ref/swift/Method/standardOutput(label:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ">standardOutput(label:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stdout</code></p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">standardOutput</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">StreamLogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L584-L586">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ"></a>
<a name="//apple_ref/swift/Method/standardError(label:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ">standardError(label:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stderr</code></p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">standardError</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">StreamLogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L589-L591">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L152">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L599-L603">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L605-L612">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:message:metadata:file:function:line:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span>
<span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span>
<span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.2.0/Sources/Logging/Logging.swift#L620-L630">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-28
View File
@@ -1,28 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="136" height="20">
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="a">
<rect width="136" height="20" rx="3" fill="#fff"/>
</clipPath>
<g clip-path="url(#a)">
<path fill="#555" d="M0 0h93v20H0z"/>
<path fill="#4c1" d="M93 0h43v20H93z"/>
<path fill="url(#b)" d="M0 0h136v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
<text x="475" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="830">
documentation
</text>
<text x="475" y="140" transform="scale(.1)" textLength="830">
documentation
</text>
<text x="1135" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">
100%
</text>
<text x="1135" y="140" transform="scale(.1)" textLength="330">
100%
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

-200
View File
@@ -1,200 +0,0 @@
/* Credit to https://gist.github.com/wataru420/2048287 */
.highlight {
/* Comment */
/* Error */
/* Keyword */
/* Operator */
/* Comment.Multiline */
/* Comment.Preproc */
/* Comment.Single */
/* Comment.Special */
/* Generic.Deleted */
/* Generic.Deleted.Specific */
/* Generic.Emph */
/* Generic.Error */
/* Generic.Heading */
/* Generic.Inserted */
/* Generic.Inserted.Specific */
/* Generic.Output */
/* Generic.Prompt */
/* Generic.Strong */
/* Generic.Subheading */
/* Generic.Traceback */
/* Keyword.Constant */
/* Keyword.Declaration */
/* Keyword.Pseudo */
/* Keyword.Reserved */
/* Keyword.Type */
/* Literal.Number */
/* Literal.String */
/* Name.Attribute */
/* Name.Builtin */
/* Name.Class */
/* Name.Constant */
/* Name.Entity */
/* Name.Exception */
/* Name.Function */
/* Name.Namespace */
/* Name.Tag */
/* Name.Variable */
/* Operator.Word */
/* Text.Whitespace */
/* Literal.Number.Float */
/* Literal.Number.Hex */
/* Literal.Number.Integer */
/* Literal.Number.Oct */
/* Literal.String.Backtick */
/* Literal.String.Char */
/* Literal.String.Doc */
/* Literal.String.Double */
/* Literal.String.Escape */
/* Literal.String.Heredoc */
/* Literal.String.Interpol */
/* Literal.String.Other */
/* Literal.String.Regex */
/* Literal.String.Single */
/* Literal.String.Symbol */
/* Name.Builtin.Pseudo */
/* Name.Variable.Class */
/* Name.Variable.Global */
/* Name.Variable.Instance */
/* Literal.Number.Integer.Long */ }
.highlight .c {
color: #999988;
font-style: italic; }
.highlight .err {
color: #a61717;
background-color: #e3d2d2; }
.highlight .k {
color: #000000;
font-weight: bold; }
.highlight .o {
color: #000000;
font-weight: bold; }
.highlight .cm {
color: #999988;
font-style: italic; }
.highlight .cp {
color: #999999;
font-weight: bold; }
.highlight .c1 {
color: #999988;
font-style: italic; }
.highlight .cs {
color: #999999;
font-weight: bold;
font-style: italic; }
.highlight .gd {
color: #000000;
background-color: #ffdddd; }
.highlight .gd .x {
color: #000000;
background-color: #ffaaaa; }
.highlight .ge {
color: #000000;
font-style: italic; }
.highlight .gr {
color: #aa0000; }
.highlight .gh {
color: #999999; }
.highlight .gi {
color: #000000;
background-color: #ddffdd; }
.highlight .gi .x {
color: #000000;
background-color: #aaffaa; }
.highlight .go {
color: #888888; }
.highlight .gp {
color: #555555; }
.highlight .gs {
font-weight: bold; }
.highlight .gu {
color: #aaaaaa; }
.highlight .gt {
color: #aa0000; }
.highlight .kc {
color: #000000;
font-weight: bold; }
.highlight .kd {
color: #000000;
font-weight: bold; }
.highlight .kp {
color: #000000;
font-weight: bold; }
.highlight .kr {
color: #000000;
font-weight: bold; }
.highlight .kt {
color: #445588; }
.highlight .m {
color: #009999; }
.highlight .s {
color: #d14; }
.highlight .na {
color: #008080; }
.highlight .nb {
color: #0086B3; }
.highlight .nc {
color: #445588;
font-weight: bold; }
.highlight .no {
color: #008080; }
.highlight .ni {
color: #800080; }
.highlight .ne {
color: #990000;
font-weight: bold; }
.highlight .nf {
color: #990000; }
.highlight .nn {
color: #555555; }
.highlight .nt {
color: #000080; }
.highlight .nv {
color: #008080; }
.highlight .ow {
color: #000000;
font-weight: bold; }
.highlight .w {
color: #bbbbbb; }
.highlight .mf {
color: #009999; }
.highlight .mh {
color: #009999; }
.highlight .mi {
color: #009999; }
.highlight .mo {
color: #009999; }
.highlight .sb {
color: #d14; }
.highlight .sc {
color: #d14; }
.highlight .sd {
color: #d14; }
.highlight .s2 {
color: #d14; }
.highlight .se {
color: #d14; }
.highlight .sh {
color: #d14; }
.highlight .si {
color: #d14; }
.highlight .sx {
color: #d14; }
.highlight .sr {
color: #009926; }
.highlight .s1 {
color: #d14; }
.highlight .ss {
color: #990073; }
.highlight .bp {
color: #999999; }
.highlight .vc {
color: #008080; }
.highlight .vg {
color: #008080; }
.highlight .vi {
color: #008080; }
.highlight .il {
color: #009999; }
-396
View File
@@ -1,396 +0,0 @@
*, *:before, *:after {
box-sizing: inherit; }
body {
margin: 0;
background: #fff;
color: #333;
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
letter-spacing: .2px;
-webkit-font-smoothing: antialiased;
box-sizing: border-box; }
h1 {
font-size: 2rem;
font-weight: 700;
margin: 1.275em 0 0.6em; }
h2 {
font-size: 1.75rem;
font-weight: 700;
margin: 1.275em 0 0.3em; }
h3 {
font-size: 1.5rem;
font-weight: 700;
margin: 1em 0 0.3em; }
h4 {
font-size: 1.25rem;
font-weight: 700;
margin: 1.275em 0 0.85em; }
h5 {
font-size: 1rem;
font-weight: 700;
margin: 1.275em 0 0.85em; }
h6 {
font-size: 1rem;
font-weight: 700;
margin: 1.275em 0 0.85em;
color: #777; }
p {
margin: 0 0 1em; }
ul, ol {
padding: 0 0 0 2em;
margin: 0 0 0.85em; }
blockquote {
margin: 0 0 0.85em;
padding: 0 15px;
color: #858585;
border-left: 4px solid #e5e5e5; }
img {
max-width: 100%; }
a {
color: #4183c4;
text-decoration: none; }
a:hover, a:focus {
outline: 0;
text-decoration: underline; }
a.discouraged {
text-decoration: line-through; }
a.discouraged:hover, a.discouraged:focus {
text-decoration: underline line-through; }
table {
background: #fff;
width: 100%;
border-collapse: collapse;
border-spacing: 0;
overflow: auto;
margin: 0 0 0.85em; }
tr:nth-child(2n) {
background-color: #fbfbfb; }
th, td {
padding: 6px 13px;
border: 1px solid #ddd; }
pre {
margin: 0 0 1.275em;
padding: .85em 1em;
overflow: auto;
background: #f7f7f7;
font-size: .85em;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
code {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
.item-container p > code, .item-container li > code, .top-matter p > code, .top-matter li > code {
background: #f7f7f7;
padding: .2em; }
.item-container p > code:before, .item-container p > code:after, .item-container li > code:before, .item-container li > code:after, .top-matter p > code:before, .top-matter p > code:after, .top-matter li > code:before, .top-matter li > code:after {
letter-spacing: -.2em;
content: "\00a0"; }
pre code {
padding: 0;
white-space: pre; }
.content-wrapper {
display: flex;
flex-direction: column; }
@media (min-width: 768px) {
.content-wrapper {
flex-direction: row; } }
.header {
display: flex;
padding: 8px;
font-size: 0.875em;
background: #444;
color: #999; }
.header-col {
margin: 0;
padding: 0 8px; }
.header-col--primary {
flex: 1; }
.header-link {
color: #fff; }
.header-icon {
padding-right: 6px;
vertical-align: -4px;
height: 16px; }
.breadcrumbs {
font-size: 0.875em;
padding: 8px 16px;
margin: 0;
background: #fbfbfb;
border-bottom: 1px solid #ddd; }
.carat {
height: 10px;
margin: 0 5px; }
.navigation {
order: 2; }
@media (min-width: 768px) {
.navigation {
order: 1;
width: 25%;
max-width: 300px;
padding-bottom: 64px;
overflow: hidden;
word-wrap: normal;
background: #fbfbfb;
border-right: 1px solid #ddd; } }
.nav-groups {
list-style-type: none;
padding-left: 0; }
.nav-group-name {
border-bottom: 1px solid #ddd;
padding: 8px 0 8px 16px; }
.nav-group-name-link {
color: #333; }
.nav-group-tasks {
margin: 8px 0;
padding: 0 0 0 8px; }
.nav-group-task {
font-size: 1em;
list-style-type: none;
white-space: nowrap; }
.nav-group-task-link {
color: #808080; }
.main-content {
order: 1; }
@media (min-width: 768px) {
.main-content {
order: 2;
flex: 1;
padding-bottom: 60px; } }
.section {
padding: 0 32px;
border-bottom: 1px solid #ddd; }
.section-content {
max-width: 834px;
margin: 0 auto;
padding: 16px 0; }
.section-name {
color: #666;
display: block; }
.section-name p {
margin-bottom: inherit; }
.declaration .highlight {
overflow-x: initial;
padding: 8px 0;
margin: 0;
background-color: transparent;
border: none; }
.task-group-section {
border-top: 1px solid #ddd; }
.task-group {
padding-top: 0px; }
.task-name-container a[name]:before {
content: "";
display: block; }
.section-name-container {
position: relative; }
.section-name-container .section-name-link {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin-bottom: 0; }
.section-name-container .section-name {
position: relative;
pointer-events: none;
z-index: 1; }
.section-name-container .section-name a {
pointer-events: auto; }
.item-container {
padding: 0; }
.item {
padding-top: 8px;
width: 100%;
list-style-type: none; }
.item a[name]:before {
content: "";
display: block; }
.item .token, .item .direct-link {
padding-left: 3px;
margin-left: 0px;
font-size: 1rem; }
.item .declaration-note {
font-size: .85em;
color: #808080;
font-style: italic; }
.pointer-container {
border-bottom: 1px solid #ddd;
left: -23px;
padding-bottom: 13px;
position: relative;
width: 110%; }
.pointer {
left: 21px;
top: 7px;
display: block;
position: absolute;
width: 12px;
height: 12px;
border-left: 1px solid #ddd;
border-top: 1px solid #ddd;
background: #fff;
transform: rotate(45deg); }
.height-container {
display: none;
position: relative;
width: 100%;
overflow: hidden; }
.height-container .section {
background: #fff;
border: 1px solid #ddd;
border-top-width: 0;
padding-top: 10px;
padding-bottom: 5px;
padding: 8px 16px; }
.aside, .language {
padding: 6px 12px;
margin: 12px 0;
border-left: 5px solid #dddddd;
overflow-y: hidden; }
.aside .aside-title, .language .aside-title {
font-size: 9px;
letter-spacing: 2px;
text-transform: uppercase;
padding-bottom: 0;
margin: 0;
color: #aaa;
-webkit-user-select: none; }
.aside p:last-child, .language p:last-child {
margin-bottom: 0; }
.language {
border-left: 5px solid #cde9f4; }
.language .aside-title {
color: #4183c4; }
.aside-warning, .aside-deprecated, .aside-unavailable {
border-left: 5px solid #ff6666; }
.aside-warning .aside-title, .aside-deprecated .aside-title, .aside-unavailable .aside-title {
color: #ff0000; }
.graybox {
border-collapse: collapse;
width: 100%; }
.graybox p {
margin: 0;
word-break: break-word;
min-width: 50px; }
.graybox td {
border: 1px solid #ddd;
padding: 5px 25px 5px 10px;
vertical-align: middle; }
.graybox tr td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px; }
.slightly-smaller {
font-size: 0.9em; }
.footer {
padding: 8px 16px;
background: #444;
color: #ddd;
font-size: 0.8em; }
.footer p {
margin: 8px 0; }
.footer a {
color: #fff; }
html.dash .header, html.dash .breadcrumbs, html.dash .navigation {
display: none; }
html.dash .height-container {
display: block; }
form[role=search] input {
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 24px;
padding: 0 10px;
margin: 0;
border: none;
border-radius: 1em; }
.loading form[role=search] input {
background: white url(../img/spinner.gif) center right 4px no-repeat; }
form[role=search] .tt-menu {
margin: 0;
min-width: 300px;
background: #fbfbfb;
color: #333;
border: 1px solid #ddd; }
form[role=search] .tt-highlight {
font-weight: bold; }
form[role=search] .tt-suggestion {
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 0 8px; }
form[role=search] .tt-suggestion span {
display: table-cell;
white-space: nowrap; }
form[role=search] .tt-suggestion .doc-parent-name {
width: 100%;
text-align: right;
font-weight: normal;
font-size: 0.9em;
padding-left: 16px; }
form[role=search] .tt-suggestion:hover,
form[role=search] .tt-suggestion.tt-cursor {
cursor: pointer;
background-color: #4183c4;
color: #fff; }
form[role=search] .tt-suggestion:hover .doc-parent-name,
form[role=search] .tt-suggestion.tt-cursor .doc-parent-name {
color: #fff; }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

-124
View File
@@ -1,124 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Logging Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a title="Logging Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.2.0 Docs
</a>
(100% documented)
</p>
<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple%2Egithub%2Eio%2Fswift%2Dlog%2Fdocs%2F1%2E2%2E0%2FLogging%2Fdocsets%2FLogging%2Exml">
<img class="header-icon" src="img/dash.png"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" />
Logging Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1 id='swiftlog-docs' class='heading'>SwiftLog Docs</h1>
<p>SwiftLog is a Swift logging API package.</p>
<p>To get started with SwiftLog, <a href="../Logging/index.html"><code>import Logging</code></a>. The
most important type is <a href="https://apple.github.io/swift-log/docs/current/Logging/Structs/Logger.html"><code><a href="Structs/Logger.html">Logger</a></code></a>
which you can use to emit log messages.</p>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2020 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external">SwiftLog team</a>. All rights reserved. (Last updated: 2020-02-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
</html>
-59
View File
@@ -1,59 +0,0 @@
window.jazzy = {'docset': false}
if (typeof window.dash != 'undefined') {
document.documentElement.className += ' dash'
window.jazzy.docset = true
}
if (navigator.userAgent.match(/xcode/i)) {
document.documentElement.className += ' xcode'
window.jazzy.docset = true
}
function toggleItem($link, $content) {
var animationDuration = 300;
$link.toggleClass('token-open');
$content.slideToggle(animationDuration);
}
function itemLinkToContent($link) {
return $link.parent().parent().next();
}
// On doc load + hash-change, open any targetted item
function openCurrentItemIfClosed() {
if (window.jazzy.docset) {
return;
}
var $link = $(`.token[href="${location.hash}"]`);
$content = itemLinkToContent($link);
if ($content.is(':hidden')) {
toggleItem($link, $content);
}
}
$(openCurrentItemIfClosed);
$(window).on('hashchange', openCurrentItemIfClosed);
// On item link ('token') click, toggle its discussion
$('.token').on('click', function(event) {
if (window.jazzy.docset) {
return;
}
var $link = $(this);
toggleItem($link, itemLinkToContent($link));
// Keeps the document from jumping to the hash.
var href = $link.attr('href');
if (history.pushState) {
history.pushState({}, '', href);
} else {
location.hash = href;
}
event.preventDefault();
});
// Clicks on links to the current, closed, item need to open the item
$("a:not('.token')").on('click', function() {
if (location == this.href) {
openCurrentItemIfClosed();
}
});
-70
View File
@@ -1,70 +0,0 @@
$(function(){
var $typeahead = $('[data-typeahead]');
var $form = $typeahead.parents('form');
var searchURL = $form.attr('action');
function displayTemplate(result) {
return result.name;
}
function suggestionTemplate(result) {
var t = '<div class="list-group-item clearfix">';
t += '<span class="doc-name">' + result.name + '</span>';
if (result.parent_name) {
t += '<span class="doc-parent-name label">' + result.parent_name + '</span>';
}
t += '</div>';
return t;
}
$typeahead.one('focus', function() {
$form.addClass('loading');
$.getJSON(searchURL).then(function(searchData) {
const searchIndex = lunr(function() {
this.ref('url');
this.field('name');
this.field('abstract');
for (const [url, doc] of Object.entries(searchData)) {
this.add({url: url, name: doc.name, abstract: doc.abstract});
}
});
$typeahead.typeahead(
{
highlight: true,
minLength: 3,
autoselect: true
},
{
limit: 10,
display: displayTemplate,
templates: { suggestion: suggestionTemplate },
source: function(query, sync) {
const lcSearch = query.toLowerCase();
const results = searchIndex.query(function(q) {
q.term(lcSearch, { boost: 100 });
q.term(lcSearch, {
boost: 10,
wildcard: lunr.Query.wildcard.TRAILING
});
}).map(function(result) {
var doc = searchData[result.ref];
doc.url = result.ref;
return doc;
});
sync(results);
}
}
);
$form.removeClass('loading');
$typeahead.trigger('focus');
});
});
var baseURL = searchURL.slice(0, -"search.json".length);
$typeahead.on('typeahead:select', function(e, result) {
window.location = baseURL + result.url;
});
});
-2
View File
@@ -1,2 +0,0 @@
/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}k.fn=k.prototype={jquery:f,constructor:k,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=k.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return k.each(this,e)},map:function(n){return this.pushStack(k.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},k.extend=k.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(k.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||k.isPlainObject(n)?n:{},i=!1,a[t]=k.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},k.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t){b(e,{nonce:t&&t.nonce})},each:function(e,t){var n,r=0;if(d(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(p,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(d(Object(e))?k.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(d(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g.apply([],a)},guid:1,support:y}),"function"==typeof Symbol&&(k.fn[Symbol.iterator]=t[Symbol.iterator]),k.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var h=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,k="sizzle"+1*new Date,m=n.document,S=0,r=0,p=ue(),x=ue(),N=ue(),A=ue(),D=function(e,t){return e===t&&(l=!0),0},j={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",$=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",F=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+Line truncated
-1
View File
@@ -1 +0,0 @@
!function(){var t,l,c,e,r,h,d,f,p,y,m,g,x,v,w,Q,k,S,E,L,b,P,T,O,I,i,n,s,z=function(e){var t=new z.Builder;return t.pipeline.add(z.trimmer,z.stopWordFilter,z.stemmer),t.searchPipeline.add(z.stemmer),e.call(t,t),t.build()};z.version="2.3.5",z.utils={},z.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),z.utils.asString=function(e){return null==e?"":e.toString()},z.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],s=e[n];if(Array.isArray(s))t[n]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[n]=s}}return t},z.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},z.FieldRef.joiner="/",z.FieldRef.fromString=function(e){var t=e.indexOf(z.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),i=e.slice(t+1);return new z.FieldRef(i,r,e)},z.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+z.FieldRef.joiner+this.docRef),this._stringValue},z.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},z.Set.complete={intersect:function(e){return e},union:function(e){return e},contains:function(){return!0}},z.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},z.Set.prototype.contains=function(e){return!!this.elements[e]},z.Set.prototype.intersect=function(e){var t,r,i,n=[];if(e===z.Set.complete)return this;if(e===z.Set.empty)return e;r=this.length<e.length?(t=this,e):(t=e,this),i=Object.keys(t.elements);for(var s=0;s<i.length;s++){var o=i[s];o in r.elements&&n.push(o)}return new z.Set(n)},z.Set.prototype.union=function(e){return e===z.Set.complete?z.Set.complete:e===z.Set.empty?this:new z.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},z.idf=function(e,t){var r=0;for(var i in e)"_index"!=i&&(r+=Object.keys(e[i]).length);var n=(t-r+.5)/(r+.5);return Math.log(1+Math.abs(n))},z.Token=function(e,t){this.str=e||"",this.metadata=t||{}},z.Token.prototype.toString=function(){return this.str},z.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},z.Token.prototype.clone=function(e){return e=e||function(e){return e},new z.Token(e(this.str,this.metadata),this.metadata)},z.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return new z.Token(z.utils.asString(e).toLowerCase(),z.utils.clone(t))});for(var r=e.toString().trim().toLowerCase(),i=r.length,n=[],s=0,o=0;s<=i;s++){var a=s-o;if(r.charAt(s).match(z.tokenizer.separator)||s==i){if(0<a){var u=z.utils.clone(t)||{};u.position=[o,a],u.index=n.length,n.push(new z.Token(r.slice(o,s),u))}o=s+1}}return n},z.tokenizer.separator=/[\s\-]+/,z.Pipeline=function(){this._stack=[]},z.Pipeline.registeredFunctions=Object.create(null),z.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&z.utils.warn("Overwriting existing registered function: "+t),e.label=t,z.Pipeline.registeredFunctions[e.label]=e},z.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||z.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},z.Pipeline.load=function(e){var r=new z.Pipeline;return e.forEach(function(e){var t=z.Pipeline.registeredFunctions[e];if(!t)throw new Error("Cannot load unregistered function: "+e);r.add(t)}),r},z.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){z.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},z.Pipeline.prototype.after=function(e,t){z.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},z.Pipeline.prototype.before=function(e,t){z.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,t)},z.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},z.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var i=this._stack[r],n=[],s=0;s<e.length;s++){var o=i(e[s],s,e);if(void 0!==o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)n.push(o[a]);else n.push(o)}e=n}return e},z.Pipeline.prototype.runString=function(e,t){var r=new z.Token(e,t);return this.run([r]).map(function(e){return e.toString()})},z.Pipeline.prototype.reset=function(){this._stack=[]},z.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return z.Pipeline.warnIfFunctionNotRegistered(e),e.label})},z.Vector=function(e){this._magnitude=0,this.elements=e||[]},z.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;Line truncated
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1 +0,0 @@
{"Structs/StreamLogHandler.html#/s:7Logging16StreamLogHandlerV14standardOutput5labelACSS_tFZ":{"name":"standardOutput(label:)","abstract":"<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stdout</code></p>","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging16StreamLogHandlerV13standardError5labelACSS_tFZ":{"name":"standardError(label:)","abstract":"<p>Factory that makes a <code>StreamLogHandler</code> to directs its output to <code>stderr</code></p>","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp":{"name":"logLevel","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp":{"name":"metadata","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip":{"name":"subscript(metadataKey:)","parent_name":"StreamLogHandler"},"Structs/StreamLogHandler.html#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF":{"name":"log(level:message:metadata:file:function:line:)","parent_name":"StreamLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging19MultiplexLogHandlerVyACSayAA0cD0_pGcfc":{"name":"init(_:)","abstract":"<p>Create a <code>MultiplexLogHandler</code>.</p>","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp":{"name":"logLevel","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF":{"name":"log(level:message:metadata:file:function:line:)","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp":{"name":"metadata","parent_name":"MultiplexLogHandler"},"Structs/MultiplexLogHandler.html#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip":{"name":"subscript(metadataKey:)","parent_name":"MultiplexLogHandler"},"Structs/Logger/Message.html#/s:s26ExpressibleByStringLiteralP0cD4TypeQa":{"name":"StringLiteralType","parent_name":"Message"},"Structs/Logger/Message.html#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc":{"name":"init(stringLiteral:)","parent_name":"Message"},"Structs/Logger/Message.html#/s:s23CustomStringConvertibleP11descriptionSSvp":{"name":"description","parent_name":"Message"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5traceyA2EmF":{"name":"trace","abstract":"<p>Appropriate for messages that contain information only when debugging a program.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5debugyA2EmF":{"name":"debug","abstract":"<p>Appropriate for messages that contain information normally of use only when","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO4infoyA2EmF":{"name":"info","abstract":"<p>Appropriate for informational messages.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO6noticeyA2EmF":{"name":"notice","abstract":"<p>Appropriate for conditions that are not error conditions, but that may require","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO7warningyA2EmF":{"name":"warning","abstract":"<p>Appropriate for messages that are not error conditions, but more severe than","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO5erroryA2EmF":{"name":"error","abstract":"<p>Appropriate for error conditions.</p>","parent_name":"Level"},"Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO8criticalyA2EmF":{"name":"critical","abstract":"<p>Appropriate for critical error conditions that usually require immediate","parent_name":"Level"},"Structs/Logger/Level.html#/s:SL1loiySbx_xtFZ":{"name":"<(_:_:)","parent_name":"Level"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF":{"name":"string(_:)","abstract":"<p>A metadata value which is a <code>String</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF":{"name":"stringConvertible(_:)","abstract":"<p>A metadata value which is some <code>CustomStringConvertible</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF":{"name":"dictionary(_:)","abstract":"<p>A metadata value which is a dictionary from <code>String</code> to <code>Logger.MetadataValue</code>.</p>","parent_name":"MetadataValue"},"Structs/Logger/MetadataValue.html#/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF":{"name":"array(_:)","abstract":"<p>A metadata value which is an array of <code>Logger.MetadataValue</code>sLine truncated
-6
View File
@@ -1,6 +0,0 @@
{
"warnings": [
],
"source_directory": "/code"
}
-162
View File
@@ -1,162 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Enumerations Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Enumerations" class="dashAnchor"></a>
<a title="Enumerations Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" alt=""/>
Enumerations Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Enumerations</h1>
<p>The following enumerations are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO"></a>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO">LoggingSystem</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
<a href="Enums/LoggingSystem.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L652-L691">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
-192
View File
@@ -1,192 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LoggingSystem Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/LoggingSystem" class="dashAnchor"></a>
<a title="LoggingSystem Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="../img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" alt=""/>
LoggingSystem Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>LoggingSystem</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">LoggingSystem</span></code></pre>
</div>
</div>
<p>The <code>LoggingSystem</code> is a global facility where the default logging backend implementation (<code><a href="../Protocols/LogHandler.html">LogHandler</a></code>) can be
configured. <code>LoggingSystem</code> is set up just once in a given program to set up the desired logging backend
implementation.</p>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L652-L691">Show on GitHub</a>
</div>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ"></a>
<a name="//apple_ref/swift/Method/bootstrap(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging0A6SystemO9bootstrapyyAA10LogHandler_pSScFZ">bootstrap(_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>bootstrap</code> is a one-time configuration function which globally selects the desired logging backend
implementation. <code>bootstrap</code> can be called at maximum once in any given program, calling it more than once will
lead to undefined behavior, most likely a crash.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">bootstrap</span><span class="p">(</span><span class="n">_</span> <span class="nv">factory</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Protocols/LogHandler.html">LogHandler</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>factory</em>
</code>
</td>
<td>
<div>
<p>A closure that given a <code><a href="../Structs/Logger.html">Logger</a></code> identifier, produces an instance of the <code><a href="../Protocols/LogHandler.html">LogHandler</a></code>.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L667-L679">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
-255
View File
@@ -1,255 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Protocols Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Protocols" class="dashAnchor"></a>
<a title="Protocols Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" alt=""/>
Protocols Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Protocols</h1>
<p>The following protocols are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP"></a>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP">LogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kd">class</span> <span class="kt">Foundation</span><span class="o">.</span><span class="kt">NSLock</span>
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">NSLock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">lock</span><span class="p">()</span>
<span class="k">defer</span> <span class="p">{</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">unlock</span><span class="p">()</span> <span class="p">}</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">source</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">lock</span><span class="p">()</span>
<span class="k">defer</span> <span class="p">{</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">unlock</span><span class="p">()</span> <span class="p">}</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="Structs/Logger.html">Logger</a></code> variable.</p>
<a href="Protocols/LogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L116-L164">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
@@ -1,538 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>LogHandler Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset="utf-8">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/LogHandler" class="dashAnchor"></a>
<a title="LogHandler Protocol Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="../img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../index.html">Logging Reference</a>
<img class="carat" src="../img/carat.png" alt=""/>
LogHandler Protocol Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>LogHandler</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">LogHandler</span></code></pre>
</div>
</div>
<p>A <code>LogHandler</code> is an implementation of a logging backend.</p>
<p>This type is an implementation detail and should not normally be used, unless implementing your own logging backend.
To use the SwiftLog API, please refer to the documentation of <code><a href="../Structs/Logger.html">Logger</a></code>.</p>
<h1 id='implementation-requirements' class='heading'>Implementation requirements</h1>
<p>To implement your own <code>LogHandler</code> you should respect a few requirements that are necessary so applications work
as expected regardless of the selected <code>LogHandler</code> implementation.</p>
<ul>
<li>The <code>LogHandler</code> must be a <code>struct</code>.</li>
<li>The metadata and <code>logLevel</code> properties must be implemented so that setting them on a <code><a href="../Structs/Logger.html">Logger</a></code> does not affect
other <code><a href="../Structs/Logger.html">Logger</a></code>s.</li>
</ul>
<h3 id='treat-log-level-amp-metadata-as-values' class='heading'>Treat log level &amp; metadata as values</h3>
<p>When developing your <code>LogHandler</code>, please make sure the following test works.</p>
<pre class="highlight swift"><code><span class="kt">LoggingSystem</span><span class="o">.</span><span class="nf">bootstrap</span><span class="p">(</span><span class="kt">MyLogHandler</span><span class="o">.</span><span class="kd">init</span><span class="p">)</span> <span class="c1">// your LogHandler might have a different bootstrapping step</span>
<span class="k">var</span> <span class="nv">logger1</span> <span class="o">=</span> <span class="kt">Logger</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="s">"first logger"</span><span class="p">)</span>
<span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">debug</span>
<span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"first"</span>
<span class="k">var</span> <span class="nv">logger2</span> <span class="o">=</span> <span class="n">logger1</span>
<span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span> <span class="o">=</span> <span class="o">.</span><span class="n">error</span> <span class="c1">// this must not override `logger1`'s log level</span>
<span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">]</span> <span class="o">=</span> <span class="s">"second"</span> <span class="c1">// this must not override `logger1`'s metadata</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">debug</span><span class="p">,</span> <span class="n">logger1</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">logger2</span><span class="o">.</span><span class="n">logLevel</span><span class="p">)</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"first"</span><span class="p">,</span> <span class="n">logger1</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
<span class="kt">XCTAssertEqual</span><span class="p">(</span><span class="s">"second"</span><span class="p">,</span> <span class="n">logger2</span><span class="p">[</span><span class="nv">metadataKey</span><span class="p">:</span> <span class="s">"only-on"</span><span class="p">])</span>
</code></pre>
<h3 id='special-cases' class='heading'>Special cases</h3>
<p>In certain special cases, the log level behaving like a value on <code><a href="../Structs/Logger.html">Logger</a></code> might not be what you want. For example,
you might want to set the log level across <em>all</em> <code><a href="../Structs/Logger.html">Logger</a></code>s to <code>.debug</code> when say a signal (eg. <code>SIGUSR1</code>) is received
to be able to debug special failures in production. This special case is acceptable but we urge you to create a
solution specific to your <code>LogHandler</code> implementation to achieve that. Please find an example implementation of this
behavior below, on reception of the signal you would call
<code>LogHandlerWithGlobalLogLevelOverride.overrideGlobalLogLevel = .debug</code>, for example.</p>
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kd">class</span> <span class="kt">Foundation</span><span class="o">.</span><span class="kt">NSLock</span>
<span class="kd">public</span> <span class="kd">struct</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="p">:</span> <span class="kt">LogHandler</span> <span class="p">{</span>
<span class="c1">// the static properties hold the globally overridden log level (if overridden)</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">let</span> <span class="nv">overrideLock</span> <span class="o">=</span> <span class="kt">NSLock</span><span class="p">()</span>
<span class="kd">private</span> <span class="kd">static</span> <span class="k">var</span> <span class="nv">overrideLogLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="c1">// this holds the log level if not overridden</span>
<span class="kd">private</span> <span class="k">var</span> <span class="nv">_logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="o">=</span> <span class="o">.</span><span class="n">info</span>
<span class="c1">// metadata storage</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span> <span class="o">=</span> <span class="p">[:]</span>
<span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">label</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span>
<span class="c1">// when we get asked for the log level, we check if it was globally overridden or not</span>
<span class="k">get</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">lock</span><span class="p">()</span>
<span class="k">defer</span> <span class="p">{</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">unlock</span><span class="p">()</span> <span class="p">}</span>
<span class="k">return</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="p">??</span> <span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span>
<span class="p">}</span>
<span class="c1">// we set the log level whenever we're asked (note: this might not have an effect if globally</span>
<span class="c1">// overridden)</span>
<span class="k">set</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">_logLevel</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">source</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// [...]</span>
<span class="p">}</span>
<span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">metadataKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span>
<span class="k">get</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span>
<span class="p">}</span>
<span class="nf">set</span><span class="p">(</span><span class="n">newValue</span><span class="p">)</span> <span class="p">{</span>
<span class="k">self</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="n">metadataKey</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// this is the function to globally override the log level, it is not part of the `LogHandler` protocol</span>
<span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">overrideGlobalLogLevel</span><span class="p">(</span><span class="n">_</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="p">{</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">lock</span><span class="p">()</span>
<span class="k">defer</span> <span class="p">{</span> <span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLock</span><span class="o">.</span><span class="nf">unlock</span><span class="p">()</span> <span class="p">}</span>
<span class="kt">LogHandlerWithGlobalLogLevelOverride</span><span class="o">.</span><span class="n">overrideLogLevel</span> <span class="o">=</span> <span class="n">logLevel</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre>
<p>Please note that the above <code>LogHandler</code> will still pass the &lsquo;log level is a value&rsquo; test above it iff the global log
level has not been overridden. And most importantly it passes the requirement listed above: A change to the log
level on one <code><a href="../Structs/Logger.html">Logger</a></code> should not affect the log level of another <code><a href="../Structs/Logger.html">Logger</a></code> variable.</p>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L116-L164">Show on GitHub</a>
</div>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata6source4file8function4lineyAA6LoggerV5LevelO_AM7MessageVSDySSAM13MetadataValueOGSgS3SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:source:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata6source4file8function4lineyAA6LoggerV5LevelO_AM7MessageVSDySSAM13MetadataValueOGSgS3SSutF">log(level:<wbr>message:<wbr>metadata:<wbr>source:<wbr>file:<wbr>function:<wbr>line:<wbr>)</a>
</code>
<span class="declaration-note">
Default implementation
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>This method is called when a <code>LogHandler</code> must emit a log message. There is no need for the <code>LogHandler</code> to
check if the <code>level</code> is above or below the configured <code><a href="../Protocols/LogHandler.html#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a></code> as <code><a href="../Structs/Logger.html">Logger</a></code> already performed this check and
determined that a message should be logged.</p>
</div>
<h4>Default Implementation</h4>
<div class="default_impl abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span>
<span class="nv">message</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span>
<span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span>
<span class="nv">source</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
<span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
<span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span>
<span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>level</em>
</code>
</td>
<td>
<div>
<p>The log level the message was logged at.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>message</em>
</code>
</td>
<td>
<div>
<p>The message to log. To obtain a <code>String</code> representation call <code>message.description</code>.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>metadata</em>
</code>
</td>
<td>
<div>
<p>The metadata associated to this log message.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>source</em>
</code>
</td>
<td>
<div>
<p>The source where the log message originated, for example the logging module.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>file</em>
</code>
</td>
<td>
<div>
<p>The file the log message was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>function</em>
</code>
</td>
<td>
<div>
<p>The function the log line was emitted from.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>line</em>
</code>
</td>
<td>
<div>
<p>The line the log message was emitted from.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L129">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF"></a>
<a name="//apple_ref/swift/Method/log(level:message:metadata:file:function:line:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP3log5level7message8metadata4file8function4lineyAA6LoggerV5LevelO_AL7MessageVSDySSAL13MetadataValueOGSgS2SSutF">log(level:<wbr>message:<wbr>metadata:<wbr>file:<wbr>function:<wbr>line:<wbr>)</a>
</code>
<span class="declaration-note">
Default implementation
</span>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>SwiftLog 1.0 compatibility method. Please do <em>not</em> implement, implement
<code><a href="../Protocols/LogHandler.html#/s:7Logging10LogHandlerP3log5level7message8metadata6source4file8function4lineyAA6LoggerV5LevelO_AM7MessageVSDySSAM13MetadataValueOGSgS3SSutF">log(level:message:metadata:source:file:function:line:)</a></code> instead.</p>
</div>
<h4>Default Implementation</h4>
<div class="default_impl abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">@available</span><span class="p">(</span><span class="o">*</span><span class="p">,</span> <span class="n">deprecated</span><span class="p">,</span> <span class="nv">renamed</span><span class="p">:</span> <span class="s">"log(level:message:metadata:source:file:function:line:﹚"</span><span class="p">)</span>
<span class="kd">func</span> <span class="nf">log</span><span class="p">(</span><span class="nv">level</span><span class="p">:</span> <span class="kt">Logging</span><span class="o">.</span><span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">message</span><span class="p">:</span> <span class="kt">Logging</span><span class="o">.</span><span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Message</span><span class="p">,</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt">Logging</span><span class="o">.</span><span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="p">?,</span> <span class="nv">file</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">function</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">line</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L140">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip"></a>
<a name="//apple_ref/swift/Method/subscript(metadataKey:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP11metadataKeyAA6LoggerV13MetadataValueOSgSS_tcip">subscript(metadataKey:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Add, remove, or change the logging metadata.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p><code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.</p>
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="nf">subscript</span><span class="p">(</span><span class="n">metadataKey</span> <span class="nv">_</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span><span class="o">.</span><span class="kt">Value</span><span class="p">?</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>metadataKey</em>
</code>
</td>
<td>
<div>
<p>The key for the metadata item</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L149">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp"></a>
<a name="//apple_ref/swift/Property/metadata" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8metadataSDySSAA6LoggerV13MetadataValueOGvp">metadata</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the entire metadata storage as a dictionary.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat logging metadata as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">metadata</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Metadata</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L155">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp"></a>
<a name="//apple_ref/swift/Property/logLevel" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging10LogHandlerP8logLevelAA6LoggerV0E0Ovp">logLevel</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Get or set the configured log level.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<code>LogHandler</code>s must treat the log level as a value type. This means that the change in metadata must
only affect this very <code>LogHandler</code>. It is acceptable to provide some form of global log level override
that means a change in log level on a particular <code>LogHandler</code> might not be reflected in any
<code>LogHandler</code>.
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">var</span> <span class="nv">logLevel</span><span class="p">:</span> <span class="kt"><a href="../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/LogHandler.swift#L163">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
-305
View File
@@ -1,305 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Structures Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset="utf-8">
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Structures" class="dashAnchor"></a>
<a title="Structures Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="index.html">Logging Reference</a>
<img class="carat" src="img/carat.png" alt=""/>
Structures Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Structures</h1>
<p>The following structures are available globally.</p>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV"></a>
<a name="//apple_ref/swift/Struct/Logger" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV">Logger</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A <code>Logger</code> is the central type in <code>SwiftLog</code>. Its central function is to emit log messages using one of the methods
corresponding to a log level.</p>
<p><code>Logger</code>s are value types with respect to the <code>logLevel</code> and the <code>metadata</code> (as well as the immutable <code>label</code>
and the selected <code><a href="Protocols/LogHandler.html">LogHandler</a></code>). Therefore, <code>Logger</code>s are suitable to be passed around between libraries if you want
to preserve metadata across libraries.</p>
<p>The most basic usage of a <code>Logger</code> is</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello World!"</span><span class="p">)</span>
</code></pre>
<a href="Structs/Logger.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Logger</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L38-L49">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging19MultiplexLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/MultiplexLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging19MultiplexLogHandlerV">MultiplexLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A pseudo-<code><a href="Protocols/LogHandler.html">LogHandler</a></code> that can be used to send messages to multiple other <code><a href="Protocols/LogHandler.html">LogHandler</a></code>s.</p>
<h3 id='effective-logger-level' class='heading'>Effective Logger.Level</h3>
<p>When first initialized the multiplex log handlers&rsquo; log level is automatically set to the minimum of all the
passed in log handlers. This ensures that each of the handlers will be able to log at their appropriate level
any log events they might be interested in.</p>
<p>Example:
If log handler <code>A</code> is logging at <code>.debug</code> level, and log handler <code>B</code> is logging at <code>.info</code> level, the constructed
<code>MultiplexLogHandler([A, B])</code>&lsquo;s effective log level will be set to <code>.debug</code>, meaning that debug messages will be
handled by this handler, while only logged by the underlying <code>A</code> log handler (since <code>B</code>&rsquo;s log level is <code>.info</code>
and thus it would not actually log that log message).</p>
<p>If the log level is <em>set</em> on a <code><a href="Structs/Logger.html">Logger</a></code> backed by an <code>MultiplexLogHandler</code> the log level will apply to <em>all</em>
underlying log handlers, allowing a logger to still select at what level it wants to log regardless of if the underlying
handler is a multiplex or a normal one. If for some reason one might want to not allow changing a log level of a specific
handler passed into the multiplex log handler, this is possible by wrapping it in a handler which ignores any log level changes.</p>
<h3 id='effective-logger-metadata' class='heading'>Effective Logger.Metadata</h3>
<p>Since a <code>MultiplexLogHandler</code> is a combination of multiple log handlers, the handling of metadata can be non-obvious.
For example, the underlying log handlers may have metadata of their own set before they are used to initialize the multiplex log handler.</p>
<p>The multiplex log handler acts purely as proxy and does not make any changes to underlying handler metadata other than
proxying writes that users made on a <code><a href="Structs/Logger.html">Logger</a></code> instance backed by this handler.</p>
<p>Setting metadata is always proxied through to <em>all</em> underlying handlers, meaning that if a modification like
<code>logger[metadataKey: &quot;x&quot;] = &quot;y&quot;</code> is made, all underlying log handlers that this multiplex handler was initiated with
will observe this change.</p>
<p>Reading metadata from the multiplex log handler MAY need to pick one of conflicting values if the underlying log handlers
were already initiated with some metadata before passing them into the multiplex handler. The multiplex handler uses
the order in which the handlers were passed in during its initialization as a priority indicator - the first handler&rsquo;s
values are more important than the next handlers values, etc.</p>
<p>Example:
If the multiplex log handler was initiated with two handlers like this: <code>MultiplexLogHandler([handler1, handler2])</code>.
The handlers each have some already set metadata: <code>handler1</code> has metadata values for keys <code>one</code> and <code>all</code>, and <code>handler2</code>
has values for keys <code>two</code> and <code>all</code>.</p>
<p>A query through the multiplex log handler the key <code>one</code> naturally returns <code>handler1</code>&rsquo;s value, and a query for <code>two</code>
naturally returns <code>handler2</code>&rsquo;s value. Querying for the key <code>all</code> will return <code>handler1</code>&rsquo;s value, as that handler was indicated
&ldquo;more important&rdquo; than the second handler. The same rule applies when querying for the <code>metadata</code> property of the
multiplex log handler - it constructs <code>Metadata</code> uniquing values.</p>
<a href="Structs/MultiplexLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">MultiplexLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L920-L991">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging16StreamLogHandlerV"></a>
<a name="//apple_ref/swift/Struct/StreamLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging16StreamLogHandlerV">StreamLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p><code>StreamLogHandler</code> is a simple implementation of <code><a href="Protocols/LogHandler.html">LogHandler</a></code> for directing
<code><a href="Structs/Logger.html">Logger</a></code> output to either <code>stderr</code> or <code>stdout</code> via the factory methods.</p>
<a href="Structs/StreamLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">StreamLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1076-L1156">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging012SwiftLogNoOpC7HandlerV"></a>
<a name="//apple_ref/swift/Struct/SwiftLogNoOpLogHandler" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging012SwiftLogNoOpC7HandlerV">SwiftLogNoOpLogHandler</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>No operation LogHandler, used when no logging is required</p>
<a href="Structs/SwiftLogNoOpLogHandler.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">SwiftLogNoOpLogHandler</span> <span class="p">:</span> <span class="kt"><a href="Protocols/LogHandler.html">LogHandler</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1159-L1186">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -1,391 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Level Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/Level" class="dashAnchor"></a>
<a title="Level Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="../../img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" alt=""/>
Level Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Level</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Level</span> <span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="kt">Codable</span><span class="p">,</span> <span class="kt">CaseIterable</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">:</span> <span class="kt">Comparable</span></code></pre>
</div>
</div>
<p>The log level.</p>
<p>Log levels are ordered by their severity, with <code>.trace</code> being the least severe and
<code>.critical</code> being the most severe.</p>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L737-L767">Show on GitHub</a>
</div>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5traceyA2EmF"></a>
<a name="//apple_ref/swift/Element/trace" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5traceyA2EmF">trace</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information normally of use only when
tracing the execution of a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">trace</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L740">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5debugyA2EmF"></a>
<a name="//apple_ref/swift/Element/debug" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5debugyA2EmF">debug</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that contain information normally of use only when
debugging a program.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">debug</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L744">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO4infoyA2EmF"></a>
<a name="//apple_ref/swift/Element/info" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO4infoyA2EmF">info</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for informational messages.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">info</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L747">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO6noticeyA2EmF"></a>
<a name="//apple_ref/swift/Element/notice" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">notice</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for conditions that are not error conditions, but that may require
special handling.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">notice</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L751">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO7warningyA2EmF"></a>
<a name="//apple_ref/swift/Element/warning" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO7warningyA2EmF">warning</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for messages that are not error conditions, but more severe than
<code><a href="../../Structs/Logger/Level.html#/s:7Logging6LoggerV5LevelO6noticeyA2EmF">.notice</a></code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">warning</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L755">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO5erroryA2EmF"></a>
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO5erroryA2EmF">error</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for error conditions.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">error</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L758">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV5LevelO8criticalyA2EmF"></a>
<a name="//apple_ref/swift/Element/critical" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV5LevelO8criticalyA2EmF">critical</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Appropriate for critical error conditions that usually require immediate
attention.</p>
<p>When a <code>critical</code> message is logged, the logging backend (<code><a href="../../Protocols/LogHandler.html">LogHandler</a></code>) is free to perform
more heavy-weight operations to capture system state (such as capturing stack traces) to facilitate
debugging.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="n">critical</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L766">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:SL1loiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/&lt;(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SL1loiySbx_xtFZ"><(_:<wbr>_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">Level</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L822-L824">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
@@ -1,235 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Message Structure Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Struct/Message" class="dashAnchor"></a>
<a title="Message Structure Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="../../img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" alt=""/>
Message Structure Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>Message</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Message</span> <span class="p">:</span> <span class="kt">ExpressibleByStringLiteral</span><span class="p">,</span> <span class="kt">Equatable</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">ExpressibleByStringInterpolation</span></code></pre>
</div>
</div>
<p><code>Logger.Message</code> represents a log message&rsquo;s text. It is usually created using string literals.</p>
<p>Example creating a <code>Logger.Message</code>:</p>
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">world</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"world"</span>
<span class="k">let</span> <span class="nv">myLogMessage</span><span class="p">:</span> <span class="kt">Logger</span><span class="o">.</span><span class="kt">Message</span> <span class="o">=</span> <span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span>
</code></pre>
<p>Most commonly, <code>Logger.Message</code>s appear simply as the parameter to a logging method such as:</p>
<pre class="highlight swift"><code><span class="n">logger</span><span class="o">.</span><span class="nf">info</span><span class="p">(</span><span class="s">"Hello </span><span class="se">\(</span><span class="n">world</span><span class="se">)</span><span class="s">"</span><span class="p">)</span>
</code></pre>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L860-L872">Show on GitHub</a>
</div>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L865-L867">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L869-L871">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
@@ -1,550 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MetadataValue Enumeration Reference</title>
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
<meta charset="utf-8">
<script src="../../js/jquery.min.js" defer></script>
<script src="../../js/jazzy.js" defer></script>
<script src="../../js/lunr.min.js" defer></script>
<script src="../../js/typeahead.jquery.js" defer></script>
<script src="../../js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Enum/MetadataValue" class="dashAnchor"></a>
<a title="MetadataValue Enumeration Reference"></a>
<header class="header">
<p class="header-col header-col--primary">
<a class="header-link" href="../../index.html">
Logging 1.4.2 Docs
</a>
(81% documented)
</p>
<div class="header-col--secondary">
<form role="search" action="../../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/apple/swift-log">
<img class="header-icon" src="../../img/gh.png" alt="GitHub"/>
View on GitHub
</a>
</p>
<p class="header-col header-col--secondary">
<a class="header-link" href="dash-feed://https%3A%2F%2Fapple.github.io%2Fswift-log%2Fdocs%2F1.4.2%2FLogging%2Fdocsets%2FLogging.xml">
<img class="header-icon" src="../../img/dash.png" alt="Dash"/>
Install in Dash
</a>
</p>
</header>
<p class="breadcrumbs">
<a class="breadcrumb" href="../../index.html">Logging Reference</a>
<img class="carat" src="../../img/carat.png" alt=""/>
MetadataValue Enumeration Reference
</p>
<div class="content-wrapper">
<nav class="navigation">
<ul class="nav-groups">
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Enums/LoggingSystem.html">LoggingSystem</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Protocols/LogHandler.html">LogHandler</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../../Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger.html">Logger</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/MetadataValue.html">– MetadataValue</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Level.html">– Level</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/Logger/Message.html">– Message</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/MultiplexLogHandler.html">MultiplexLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/StreamLogHandler.html">StreamLogHandler</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../../Structs/SwiftLogNoOpLogHandler.html">SwiftLogNoOpLogHandler</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section class="section">
<div class="section-content top-matter">
<h1>MetadataValue</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">MetadataValue</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">Equatable</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByStringLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">CustomStringConvertible</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByStringInterpolation</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByDictionaryLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt">MetadataValue</span><span class="p">:</span> <span class="kt">ExpressibleByArrayLiteral</span></code></pre>
</div>
</div>
<p>A logging metadata value. <code>Logger.MetadataValue</code> is string, array, and dictionary literal convertible.</p>
<p><code>MetadataValue</code> provides convenient conformances to <code>ExpressibleByStringInterpolation</code>,
<code>ExpressibleByStringLiteral</code>, <code>ExpressibleByArrayLiteral</code>, and <code>ExpressibleByDictionaryLiteral</code> which means
that when constructing <code>MetadataValue</code>s you should default to using Swift&rsquo;s usual literals.</p>
<p>Examples:</p>
<ul>
<li>prefer <code>logger.info(&quot;user logged in&quot;, metadata: [&quot;user-id&quot;: &quot;\(user.id)&quot;])</code> over
<code>..., metadata: [&quot;user-id&quot;: .string(user.id.description)])</code></li>
<li>prefer <code>logger.info(&quot;user selected colors&quot;, metadata: [&quot;colors&quot;: [&quot;\(user.topColor)&quot;, &quot;\(user.secondColor)&quot;]])</code>
over <code>..., metadata: [&quot;colors&quot;: .array([.string(&quot;\(user.topColor)&quot;), .string(&quot;\(user.secondColor)&quot;)])</code></li>
<li>prefer <code>logger.info(&quot;nested info&quot;, metadata: [&quot;nested&quot;: [&quot;fave-numbers&quot;: [&quot;\(1)&quot;, &quot;\(2)&quot;, &quot;\(3)&quot;], &quot;foo&quot;: &quot;bar&quot;]])</code>
over <code>..., metadata: [&quot;nested&quot;: .dictionary([&quot;fave-numbers&quot;: ...])])</code></li>
</ul>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L710-L731">Show on GitHub</a>
</div>
</div>
</section>
<section class="section">
<div class="section-content">
<div class="task-group">
<ul class="item-container">
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF"></a>
<a name="//apple_ref/swift/Element/string(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO6stringyAESScAEmF">string(_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a <code>String</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByStringInterpolation</code>, and <code>ExpressibleByStringLiteral</code>,
you don&rsquo;t need to type <code>.string(someType.description)</code> you can use the string interpolation <code>&quot;\(someType)&quot;</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">string</span><span class="p">(</span><span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L715">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF"></a>
<a name="//apple_ref/swift/Element/stringConvertible(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO17stringConvertibleyAEs012CustomStringF0_pcAEmF">stringConvertible(_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is some <code>CustomStringConvertible</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">stringConvertible</span><span class="p">(</span><span class="kt">CustomStringConvertible</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L718">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/dictionary(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO10dictionaryyAESDySSAEGcAEmF">dictionary(_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is a dictionary from <code>String</code> to <code>Logger.MetadataValue</code>.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByDictionaryLiteral</code>, you don&rsquo;t need to type
<code>.dictionary([&quot;foo&quot;: .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;: &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">dictionary</span><span class="p">(</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L724">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF"></a>
<a name="//apple_ref/swift/Element/array(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:7Logging6LoggerV13MetadataValueO5arrayyAESayAEGcAEmF">array(_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>A metadata value which is an array of <code>Logger.MetadataValue</code>s.</p>
<p>Because <code>MetadataValue</code> implements <code>ExpressibleByArrayLiteral</code>, you don&rsquo;t need to type
<code>.array([.string(&quot;foo&quot;), .string(&quot;bar \(buz)&quot;)])</code>, you can just use the more natural <code>[&quot;foo&quot;, &quot;bar \(buz)&quot;]</code>.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">array</span><span class="p">([</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">])</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L730">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:SQ2eeoiySbx_xtFZ"></a>
<a name="//apple_ref/swift/Method/==(_:_:)" class="dashAnchor"></a>
<a class="token" href="#/s:SQ2eeoiySbx_xtFZ">==(_:<wbr>_:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">==</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L832-L845">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP0cD4TypeQa"></a>
<a name="//apple_ref/swift/Alias/StringLiteralType" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP0cD4TypeQa">StringLiteralType</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">StringLiteralType</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc"></a>
<a name="//apple_ref/swift/Method/init(stringLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s26ExpressibleByStringLiteralP06stringD0x0cD4TypeQz_tcfc">init(stringLiteral:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">stringLiteral</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1219-L1221">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s23CustomStringConvertibleP11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:s23CustomStringConvertibleP11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">description</span><span class="p">:</span> <span class="kt">String</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1227-L1238">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP3KeyQa"></a>
<a name="//apple_ref/swift/Alias/Key" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP3KeyQa">Key</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Key</span> <span class="o">=</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP5ValueQa"></a>
<a name="//apple_ref/swift/Alias/Value" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">Value</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt">Value</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s30ExpressibleByDictionaryLiteralP010dictionaryD0x3KeyQz_5ValueQztd_tcfc">init(dictionaryLiteral:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">dictionaryLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="p">(</span><span class="kt">String</span><span class="p">,</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="p">)</span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1251-L1253">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP0cD7ElementQa"></a>
<a name="//apple_ref/swift/Alias/ArrayLiteralElement" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP0cD7ElementQa">ArrayLiteralElement</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">ArrayLiteralElement</span> <span class="o">=</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc"></a>
<a name="//apple_ref/swift/Method/init(arrayLiteral:)" class="dashAnchor"></a>
<a class="token" href="#/s:s25ExpressibleByArrayLiteralP05arrayD0x0cD7ElementQzd_tcfc">init(arrayLiteral:<wbr>)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="n">arrayLiteral</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt"><a href="../../Structs/Logger.html">Logger</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger.html#/s:7Logging6LoggerV8Metadataa">Metadata</a></span><span class="o">.</span><span class="kt"><a href="../../Structs/Logger/MetadataValue.html#/s:s30ExpressibleByDictionaryLiteralP5ValueQa">Value</a></span><span class="o">...</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/apple/swift-log/tree/1.4.2/Sources/Logging/Logging.swift#L1261-L1263">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<section class="footer">
<p>&copy; 2021 <a class="link" href="https://github.com/apple/swift-log" target="_blank" rel="external noopener">SwiftLog team</a>. All rights reserved. (Last updated: 2021-12-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.14.1</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</body>
</html>
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff. Show more