Skip to content

Commit

Permalink
Merge pull request #1 from iq3addLi/feature/add_status_to_log
Browse files Browse the repository at this point in the history
Feature/add status to log
  • Loading branch information
jagreenwood authored Sep 20, 2020
2 parents 9872cc2 + 94b58ad commit b6afbf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/DataDogLog/DataDogLogHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions Sources/DataDogLog/Log.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit b6afbf8

Please sign in to comment.