mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
wip
This commit is contained in:
32
dots/Sources/LoggingDependency/Live.swift
Normal file
32
dots/Sources/LoggingDependency/Live.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
import Dependencies
|
||||
import Foundation
|
||||
@_exported import Logging
|
||||
import LoggingFormatAndPipe
|
||||
|
||||
extension Logger: DependencyKey {
|
||||
|
||||
fileprivate static func factory(label: String) -> Self {
|
||||
Logger(label: "dots") { _ in
|
||||
LoggingFormatAndPipe.Handler(
|
||||
formatter: BasicFormatter([.message]),
|
||||
pipe: LoggerTextOutputStreamPipe.standardOutput
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public static var liveValue: Logger {
|
||||
factory(label: "dots")
|
||||
}
|
||||
|
||||
public static var testValue: Logger {
|
||||
factory(label: "dots-test")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension DependencyValues {
|
||||
public var logger: Logger {
|
||||
get { self[Logger.self] }
|
||||
set { self[Logger.self] = newValue }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user