* 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>
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
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
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).
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.
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() })
```
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.
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>
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.
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.
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>
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