tomer doron bf76e03ea3 logger metadata support and unit tests
motivation: add tests to confirm desired functionality

changes:
* add property for logger metadata (aka context)
* improve pretty-metadata (aka pretty-context) generation
* add unit tests covering local and global use cases
* add [test only] implementation of MDC
* format with swiftformat

open issues:
* should we name the new property metadata or context
* should we include a default MDC implmentation as part of the logging API. if we dont, we will encourage libraries binding to specific logging implementations that support it (that was bad in java)
* tests are a bit brittle
* why is ExampleLoggerImplementation a reference type?
2018-12-03 18:32:51 -08:00
2018-11-06 16:55:31 +00:00
2018-12-03 17:45:24 +00:00

swift-server-logger-api

This is pre-pitch stage SSWG proposal about a logger API that intends to support a number programming models:

  • explicit logger passing (see ExplicitLoggerPassingExample.swift)
  • one global logger (see OneGlobalLoggerExample.swift)
  • one logger per sub-system (see LoggerPerSubsystem.swift)

The file RandomExample.swift contains demoes of some other things that you may want to do.

Feedback Wishes

Feedback that would really be great is:

  • if anything, what does this proposal not cover that you will definitely need
  • if anything, what could we remove from this and still be happy?
  • API-wise: what do you like, what don't you like?

Feel free to post this as message on the SSWG forum and/or github issues in this repo.

Open Questions

Very many. But here a couple that come to my mind:

  • currently attaching context to a logger is done through subscript(diagnosticKey diagnosticKey: String) -> String? { get set } clearly setting and deleting extra context is necessary. But reading it is really not. Should we make it addContext(key: String, value: String) and removeContext(key:String) instead?
  • should the logging context values be String?
  • should we add an ability to read all current context?
S
Description
Mirror of github.com/apple/swift-log
Readme Apache-2.0
3.3 MiB
0 Stars 1 Watchers 0 Forks
Languages
Swift 97.5%
CMake 2.5%