Skip to content

wtg/Shuttle-Tracker-Logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shuttle Tracker Logging

This is a Swift package that implements a client for the Shuttle Tracker unified logging system on Apple platforms.

Usage

First, implement a configuration provider:

final class ConfigurationProvider: LoggingConfigurationProvider {
	enum Category: String, LoggingCategory {
		case general, network, location
		static var `default`: Self = .general
	}
	let doUploadLogs = true
	var uploadedLogs: [LoggingSystem<Category>.Log] = []
}

Note the nested Category enumeration, which specifies the available logging categories.

Next, add logic to upload logs to the remote server:

extension ConfigurationProvider: LogUploader {
	func upload(log: LoggingSystem<Category>.Log) async throws -> UUID {
		// Upload the log to the remote server and return the server-determined ID…
	}
}

Finally, use the log(system:category:level:doUpload:_:) macro to write to the logging system:

let result = 42
let configurationProvider = ConfigurationProvider()
let loggingSystem = LoggingSystem(configurationProvider: configurationProvider, uploader: configurationProvider)
#log(system: loggingSystem, level: .debug, "Hello, world! The result is \(42, privacy: .private(mask: .hash))")

About

The Shuttle Tracker unified logging system

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages