Commit Graph
16 Commits
Author SHA1 Message Date
Konrad `ktoso` Malawski 0bf0588b17 Avoids regression SR-9687 in Swift 5 by not applying extensions to type aliased type (#27) 2019-01-17 11:31:07 +00:00
Konrad `ktoso` Malawski d370d101be fix a few typos in comments (#28) 2019-01-17 11:07:19 +00:00
Johannes Weiss ba9eac9055 fixed small errors/typos etc 2019-01-14 12:36:08 +00:00
Johannes Weiss dfffdaa429 remove Metadata.Value.lazy (#18)
Motivation:

Two reasons for the removal:

1. I don't see a compelling reason to add lazy metadata to the metadata
   storage. Lazy metadata makes sense if it's passed directly to a log
   method like

       logger.info("foo", metadata: somethingExpensive())

   but I don't think this makes a whole lot of sense

       logger[metadataKey: "foo"] = .lazy({ somethingExpensive() })

   why? It's very likely that it'll get evalutated because any next
   log message that gets logged will force it but it's totally
   unclear which one that'll be.

2. More importantly, the lazy metadata can't be implemented correctly
   because we can't memoize the result of the expensive computation
   because we can only mutate the `LogHandler` in mutating methods and
   the log methods aren't mutating.
2019-01-09 15:47:09 +00:00
tomer doron a0c3ceabdf add support for local metadata (#16)
motivation: allow users to define metadata at the log API call site

changes: add metadata param to all log APIs, and implement merge at our example implementations
2019-01-09 12:04:59 +00:00
tomer doron 5ca706eb48 make logger metadata non-optional (#15)
motivation: simpler / cleaner API

changes: change logger Metadata API to be non-nullable, since the original motivation is no longer valid
2019-01-08 21:11:12 +00:00
tomer doron 19d987b6d5 add logger API variants that take an error (#12)
motivation: easily log errors w/o converting them to string first

changes:
* add another set of logger APIs that take in an error object
* add tests and refactor testing assertions
* add autoclosure tests to make sure its resoved on when log level is appropriate
2019-01-08 20:41:03 +00:00
Johannes Weiss c7ac24db1f nest types & allow nested metadata 2019-01-08 18:13:52 +00:00
tomer doron 9027df5f03 refactor examples and remove dependecy on foundation
motivation:
* due to the low level nature of the library we prefer not to force-load foundation
* help reviewers diffrentiate between examples of usage vs implementation, and add more realistic usage and implementations examples

changes:
* remove foundation from Logging module, replace with c based locks and time functions
* rewrite usage examples to be more realistic
* add example of an implementation that writes to files
* add example of an implementation that is config driven
* rename warn -> warning
2019-01-05 02:03:44 -08:00
tomer doron 132af4ff5a add multiplex logger
motivation: support situations when users want to multiplex to multiple logging implementations

changes:
* add MultiplexLogging (factory) and MUXLogHandler (implementation), allowing user to plug in multiple logging implementations
* add tests and examples to demonstrate the functionality
2019-01-02 14:58:37 -08:00
Johannes Weiss 50a8c8fdac use the term "metadata" 2018-12-12 17:43:59 +00:00
tomer doron b5dcb3140e naming proposal (#2)
* naming proposal

motivation: intuitive APIs

changes:
* Logger is the main API users interact with
* Logging is the factory from which users get instances of Logger, via Logging.for(identifer)
* LogHandler is what logging libraries implement, this is not exposed to users as its boxed in Logger
* replace Logging (aka LoggerFactory) factory property with bootstrap(factory) function
* rename main module to Logging since its not server only
* converge examples into an Examples module

open questions:
* Logging.make or Logging.for
* is Logging.for(object: Any.Type) a good idea? is there a better way to get the FQN for an object?
2018-12-10 15:11:03 -08:00
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
Johannes Weiss edd354fa76 hide the existential 2018-12-03 17:43:55 +00:00
Johannes Weiss c5c893e7ff evaluate @autoclosure before passing to existential 2018-11-30 21:36:59 +00:00
Johannes Weiss d756065630 initial commit 2018-11-06 16:55:31 +00:00