mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
Multiple proposal improvements to the API (#41)
* Move `Logging.make` to a `Logger` initializer. * Remove all factory initializers in example and test code.
This commit is contained in:
1 parent
03174f3260
commit
2474d61a80
19 files changed
+336
-376
No files matched your search
@@ -12,8 +12,7 @@ import Logging
|
||||
enum ContextBasedSystem {
|
||||
static func main() {
|
||||
// boostrap with our sample implementation
|
||||
let logging = SimpleLogging()
|
||||
Logging.bootstrap(logging.make)
|
||||
Logging.bootstrap(SimpleLogHandler.init)
|
||||
// run the example
|
||||
for i in 1 ... 2 {
|
||||
print("---------------------------- processing request #\(i) ----------------------------")
|
||||
@@ -23,14 +22,14 @@ enum ContextBasedSystem {
|
||||
}
|
||||
|
||||
struct Context {
|
||||
var logger = Logging.make("ContextLogger")
|
||||
var logger = Logger(label: "ContextLogger")
|
||||
|
||||
init(metadata: Logging.Metadata = [:]) {
|
||||
init(metadata: Logger.Metadata = [:]) {
|
||||
metadata.forEach { self[$0.0] = $0.1 }
|
||||
}
|
||||
|
||||
// since logger is a value type, we can reuse our copy to manage the metadata
|
||||
subscript(metadataKey: String) -> Logging.Metadata.Value? {
|
||||
subscript(metadataKey: String) -> Logger.Metadata.Value? {
|
||||
get { return self.logger[metadataKey: metadataKey] }
|
||||
set { self.logger[metadataKey: metadataKey] = newValue }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user