diff --git a/Sources/DataDogLog/DataDogLogHandler.swift b/Sources/DataDogLog/DataDogLogHandler.swift index e25ac37..07ef53f 100644 --- a/Sources/DataDogLog/DataDogLogHandler.swift +++ b/Sources/DataDogLog/DataDogLogHandler.swift @@ -27,7 +27,7 @@ public struct DataDogLogHandler: LogHandler { let logMetadata = metadata.map { $0.merging(callsite) { $1 } } ?? callsite let mergedMetadata = self.metadata.merging(logMetadata) { $1 } let ddMessage = Message(level: level, message: "\(message)") - let log = Log(ddsource: label, ddtags: "\(mergedMetadata.prettified.map { "\($0)" } ?? "")", hostname: self.hostname ?? "", message: "\(ddMessage)") + let log = Log(ddsource: label, ddtags: "\(mergedMetadata.prettified.map { "\($0)" } ?? "")", hostname: self.hostname ?? "", message: "\(ddMessage)", status: "\(level)") session.send(log, key: key, region: region) { result in if case .failure(let message) = result { diff --git a/Sources/DataDogLog/Log.swift b/Sources/DataDogLog/Log.swift index ecbbc3b..3499a35 100644 --- a/Sources/DataDogLog/Log.swift +++ b/Sources/DataDogLog/Log.swift @@ -1,10 +1,19 @@ import Logging +/// Attribute for Datadog Logs +/// +/// See https://docs.datadoghq.com/logs/log_collection/#reserved-attributes struct Log: Encodable { let ddsource: String let ddtags: String let hostname: String let message: String + + /// Log Status + /// + /// Logger.Level.trace will be sorted into Datadog as .debug. + /// See https://docs.datadoghq.com/logs/processing/processors/#log-status-remapper for details. + let status: String } struct Message: CustomStringConvertible {