Commit Graph

28 Commits

Author SHA1 Message Date
Olivier Poitrey 1dde226d45 BasicSampler prints first message (fix #104) 2018-09-16 15:54:54 -07:00
Dušan Kasan 1c6d99b455 Add custom error serialization support and provide sane defaults (#78)
As per https://github.com/rs/zerolog/issues/9 and to offer a different approach from  https://github.com/rs/zerolog/pull/11 and https://github.com/rs/zerolog/pull/35 this PR introduces custom error serialization with sane defaults without breaking the existing APIs.

This is just a first draft and is missing tests. Also, a bit of code duplication which I feel could be reduced but it serves to get the idea across.

It provides global error marshalling by exposing a `var ErrorMarshalFunc func(error) interface{}` in zerolog package that by default is  a function that returns the passed argument. It should be overriden if you require custom error marshalling.

Then in every function that accept error or array of errors `ErrorMarshalFunc` is called on the error and then the result of it is processed like this:
- if it implements `LogObjectMarshaler`, serialize it as an object
- if it is a string serialize as a string
- if it is an error, serialize as a string with the result of `Error()`
- else serialize it as an interface

The side effect of this change is that the encoders don't need the `AppendError/s` methods anymore, as the errors are serialized directly to other types.
2018-07-02 12:46:01 -07:00
Olivier Poitrey a572c9d1f6 Add missing support for zerolog marshable objects to Fields 2018-05-09 03:52:30 -07:00
Ravi Raju 70bea47cc0 Fix for a bug in cbor decodeFloat (#51) 2018-04-13 00:13:41 -07:00
Ravi Raju 2ccfab3e07 Support for adding IP Address/Prefix + stream based decoder (#49)
* added IPAddr, IPPrefix and stream based cbor decoder
* Update README with cbor decoder tool info
* Update README in cbor with comparison data
2018-04-03 23:07:18 +02:00
Ravi Raju ddfae1b613 Binary format support (#37)
Adds support for binary logging (with cbor encoding) in addition to JSON. Use the binary_log compile tag to enable the feature.
2018-03-28 11:49:41 -07:00
Olivier Poitrey d0ca9bbceb Add support for pointer values in Fields
Fixes #46
2018-03-25 20:18:47 -07:00
Max Wolter 1c575db928 Add support for hex-encoded of byte slice (#42) 2018-03-15 10:29:26 -07:00
Olivier Poitrey 56a970de51 Add RawJSON field type 2018-02-12 16:05:27 -08:00
Olivier Poitrey 27e0a22cbc Add the ability to capture the logger caller file and line number
Fixes #34, #22
2018-02-07 13:54:26 -08:00
Olivier Poitrey fcbdf23e9e Use new hook internally to handle timestamp in context 2018-02-07 13:31:00 -08:00
Rodrigo Coelho c3d02683c7 Add hook support (#24) 2017-12-01 10:52:37 -07:00
Ravi Raju 9a65e7ccd2 Fix Output with existing context (fix #20)
Also includes tests for Output()
2017-11-08 10:47:56 -08:00
Giovanni Bajo 89e128fdc1 Speed up operations when logging is disabled. (#18)
Low-level optimizations to help the compiler generate better code
when logging is disabled. Measured improvement is ~30% on amd64
(from 21 ns/op to 16 ns/op).
2017-11-05 05:22:20 -08:00
Olivier Poitrey 9e5c06cf0e Add more advanced sampling modes 2017-08-28 23:30:54 -07:00
Olivier Poitrey 2aa3c3ae4f Add some array types support 2017-07-25 12:50:35 -07:00
Olivier Poitrey 7af653895b Add utility functions WithLevel and Fields
Add some utility functions to ease migration from other logger API.
2017-07-10 02:58:58 -07:00
Olivier Poitrey 15fc33fe89 Fix sloppy test 2017-06-25 01:12:41 -07:00
Olivier Poitrey 2a829377cb Rename warning field to warn in the output 2017-06-08 10:03:03 -07:00
Olivier Poitrey 9889521807 Add TimeDiff event method 2017-06-06 22:10:36 -07:00
Olivier Poitrey 49d553c9b8 Add AnErr field type 2017-06-02 00:56:14 -07:00
Olivier Poitrey e0e86f933f Add Msgf test 2017-05-20 20:59:39 -07:00
Olivier Poitrey 19a9a81cd2 Add some more doc 2017-05-20 02:22:57 -07:00
Olivier Poitrey 156a4e8b0f Use TimeFieldFormat for Timestamp field 2017-05-19 22:14:51 -07:00
Olivier Poitrey fa2d76dd80 Add some test 2017-05-19 21:57:46 -07:00
Olivier Poitrey 5ebf00efab Add dict support 2017-05-18 00:10:45 -07:00
Olivier Poitrey aff9804294 Test fields and context 2017-05-16 22:24:36 -07:00
Olivier Poitrey 7f302b00ec Initial commit 2017-05-13 16:22:35 -07:00