@@ -13,25 +13,24 @@ import Logging
1313/**
1414 A logger that logs it’s messages to stdout in the JSON format, one log per line.
1515
16- The line separator is actually customizable, and can be any sequence of bytes.
16+ The end of line separator is actually customizable, and can be any sequence of bytes.
1717 By default it’s “`\n`”.
1818
1919 The separator customization allows you to choose
2020 a prefix for the JSON payload (defaults to `[]`),
21- a suffix too (defaults to `[]` too ),
22- and an inter-JSON separator (defaults to `[0x0a ]`, which is a UNIX newline ).
21+ a suffix too (defaults to `[0x0a]`, aka. a single UNIX newline ),
22+ and an inter-JSON separator (defaults to `[]`, same as the prefix ).
2323 For instance if there are two messages logged, you’ll get the following written to the fd:
2424 ```
2525 prefix JSON1 suffix separator prefix JSON2 suffix
2626 ```
2727
28- This configuration is interesting mostly to generate `json-seq` stream.
29- To do this, set the inter-JSON separator to `[]`, the prefix to `[0x1e]` and the suffix to `[0x0a]`,
30- or use the convenience ``forJSONSeq(on:label:metadataProvider:)``.
28+ An interesting configuration is setting the prefix to `[0x1e]` and the suffix to `[0x0a]`, which generates a `json-seq` stream.
29+ You can use the ``forJSONSeq(on:label:metadataProvider:)`` convenience to get this configuration directly.
3130
32- Finally, another interesting configuration is to set the separator to `[0xff]` or `[0xfe]`.
31+ Another interesting configuration is to set the inter-JSON separator to `[0xff]` or `[0xfe]` (or both) .
3332 These bytes should not appear in valid UTF-8 strings and should be able to be used to separate JSON payloads.
34- (Note I’m not sure why `json-seq` does not do that; there must be a good reason, though .
33+ (Note I’m not sure why `json-seq` does not do that but there must be a good reason.
3534 Probably because the resulting output would not be valid UTF-8 anymore.)
3635
3736 The output file descriptor is also customizable and is `stdout` by default. */
@@ -113,7 +112,7 @@ public struct JSONLogger : LogHandler {
113112 public init (
114113 label: String ,
115114 fd: FileDescriptor = . standardOutput,
116- lineSeparator: Data = Data ( " \n " . utf8 ) , prefix: Data = Data ( ) , suffix: Data = Data ( ) ,
115+ lineSeparator: Data = Data ( ) , prefix: Data = Data ( ) , suffix: Data = Data ( " \n " . utf8 ) ,
117116 jsonEncoder: JSONEncoder = Self . defaultJSONEncoder,
118117 jsonCodersForStringConvertibles: ( JSONEncoder , JSONDecoder ) = Self . defaultJSONCodersForStringConvertibles,
119118 metadataProvider: Logger . MetadataProvider ? = LoggingSystem . metadataProvider
0 commit comments