* =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>
* 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)
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
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>
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.
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
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.
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
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
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
* 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
* 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
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
LoggingFormatAndPipe provides a Swift Logging API Handler which allows you to customized both your log messages' formats as well as their destinations.
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).
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)
])
}
```
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.