Meshtastic-Apple/Meshtastic/Extensions/Logger+DataDog.swift
Garth Vander Houwen 1b98ae97cd
2.7.3 Working Changes (#1404)
* Remove non functional module override button

* Remove stale keys

* Onboarding and lora config bug fixes

* Add Annotations view and try and simplify online annimations to improve performance.

* Bump version

* Fix proto bug

* Don't show ignored nodes on the mesh map

* More node annotation animation improvements

* Ham

* Remove liquid glass form icon

* Update MQTT config logic

* Liquid glass chirpy and ham on the watch

* Use Hops away value for DM's (#1409)

* Set hopLimit for DM messages (DM's and Exchange position) to the hops away value for the node you are sending to.

* Update Meshtastic/Accessory/Accessory Manager/AccessoryManager+ToRadio.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Icons

* 🐰

* DataDog action logging (#1411)

Co-authored-by: Jake-B <jake-b@users.noreply.github.com>

* Update location usage details

* Good doggo (#1414)

* DataDog action logging

* Filter version hash

---------

Co-authored-by: Jake-B <jake-b@users.noreply.github.com>

* Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/Helpers/LocationsHandler.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/Views/Nodes/Helpers/Map/MapContent/AnimatedNodePin.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: jake-b <1012393+jake-b@users.noreply.github.com>
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-09-18 13:19:45 -07:00

69 lines
1.9 KiB
Swift

//
// Logger+DataDog.swift
// Meshtastic
//
// Created by Jake Bordens on 9/17/25.
//
import Foundation
import os.log
import DatadogRUM
import DatadogLogs
struct DatadogLogger {
private let osLogger: os.Logger
private let ddLogger: any DatadogLogs.LoggerProtocol
// Initialize with a subsystem and category, similar to Logger
fileprivate init(subsystem: String, category: String) {
self.osLogger = Logger(subsystem: subsystem, category: category)
self.ddLogger = DatadogLogs.Logger.create(
with: Logger.Configuration(
name: "gvh.Meshtastic",
networkInfoEnabled: true,
remoteLogThreshold: .debug,
consoleLogFormat: .short
)
)
}
// os.Logger functions like debug, info, etc., are not normal functions.
// They rely on compiler magic to parse the interpolated string, identify the
// privacy modifiers (.public, .private), and handle the data securely without
// ever creating a potentially sensitive string in your app's memory.
// To do this, the compiler must see the string literal at the point of the call.
// Since this is going to Datadog, care should be taken to only use these functions
// with public debug data.
func debug(_ message: String) {
osLogger.debug("\(message, privacy: .public)")
ddLogger.debug(message)
}
func info(_ message: String) {
osLogger.info("\(message, privacy: .public)")
ddLogger.info(message)
}
func warning(_ message: String) {
osLogger.warning("\(message, privacy: .public)")
ddLogger.warn(message)
}
func error(_ message: String) {
osLogger.error("\(message, privacy: .public)")
ddLogger.error(message)
}
// MARK: - Methods for RUM actions
func action(name: String, attributes: [String: any Encodable]? = nil) {
RUMMonitor.shared().addAction(
type: .custom,
name: name,
attributes: attributes ?? [:]
)
}
}
extension os.Logger {
static let datadog = DatadogLogger(subsystem: "datadog", category: "🐶 DataDog")
}