Skip to content

Commit d60fd8e

Browse files
committed
Create a new multiline log style
1 parent 8835478 commit d60fd8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/CLTLogger.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public struct CLTLogger : LogHandler {
8383
/**
8484
Multiline logs are allowed.
8585

86+
The metadata are printed on one line on the same line as the last line of the log. */
87+
case allowMultilineWithMetadataOnLastLine
88+
/**
89+
Multiline logs are allowed.
90+
8691
The metadata are printed on the same line as the log, _unless_ the log is multiline,
8792
in which case there are printed after, one line per metadata.
8893

@@ -325,6 +330,15 @@ private extension CLTLogger {
325330
message += lineSeparator
326331
return Data(message.utf8)
327332

333+
case .allowMultilineWithMetadataOnLastLine:
334+
var message = constants.logPrefix + message.processForLogging(escapingMode: .escapeScalars(octothorpLevel: 1), newLineProcessing: .replace(replacement: lineSeparator + constants.multilineLogPrefix)).string
335+
if !flatMetadata.isEmpty {
336+
message += constants.logAndMetadataSeparator
337+
}
338+
message += flatMetadata.joined(separator: constants.metadataSeparator)
339+
message += lineSeparator
340+
return Data(message.utf8)
341+
328342
case .allowMultilineWithMetadataOnSameLineUnlessMultiLineLogs:
329343
let (tweakedMessage, hasTweaked) = message.processForLogging(escapingMode: .escapeScalars(octothorpLevel: 1), newLineProcessing: .replace(replacement: lineSeparator + constants.multilineLogPrefix))
330344
var message = constants.logPrefix + tweakedMessage

0 commit comments

Comments
 (0)