Commit Graph

250 Commits

Author SHA1 Message Date
Olivier Poitrey a06edf20d7
Fix zerolog.SetGlobalLevel readme 2020-04-20 13:50:01 -07:00
Blake Williams fe394c81ce
Remove dependency on Goji (#223) 2020-04-12 22:02:06 -07:00
haozibi 1c32ee06a7
Fix: Event.stack initialization error (#219) 2020-03-30 10:16:40 -07:00
Milo d9df1802de
Updated README (#212)
Updated README to reflect changes in the code - included new field types available, corrected typos.
2020-02-15 09:27:26 -08:00
Olivier Poitrey f7c93dce1c Fix test on non linux platform 2020-02-10 17:16:38 -08:00
Olivier Poitrey 68a3fd989d Fix a crash condition when AnErr is used with a nil interface 2020-02-10 17:15:06 -08:00
Ilja Neumann 505b18daf2 Return written size when message was sent without error (#190)
- Fixes ErrShortWrite error if used with io.MultiWriter
2020-01-15 13:01:51 -08:00
Ryo Ota 65ed30bfb0 Use ```bash instead of ```go (#209) 2020-01-01 12:32:59 -08:00
Dmitry Savintsev cb951d468e fix the typo in 'guarantee' (#203) 2019-12-27 09:23:15 -08:00
wphan d2a97b366b fix ConsoleWriter for TimeFormatMicro (#206) 2019-12-20 09:34:21 -08:00
Olivier Poitrey f1dd50b8c6 Fix trace again 2019-11-18 16:32:52 -08:00
Olivier Poitrey 686705b4f0 Remove Trace from SyslogWriter interface 2019-11-18 16:29:37 -08:00
Olivier Poitrey 5d9d7660cc Expose the Err helper from the global logger 2019-11-18 16:22:50 -08:00
Olivier Poitrey 54e95fe699 Fix numbering of levels 2019-11-18 09:34:23 -08:00
guonaihong e709c5d91e Allow custom caller level (#196)
To modify the Caller, you can pass a jump to a few function call stacks.

```go
package main

import (
    "github.com/rs/zerolog"
    "github.com/rs/zerolog/log"
)

func myError() {
    log.Debug().Caller(1).Str("test2", "v2").Send()
}

func foo() {
    log.Debug().Caller(2).Str("test2", "v2").Send()
}

func myError2() {
    foo()
}
func main() {
    zerolog.TimeFieldFormat = zerolog.TimeFormatUnix

    log.Debug().Caller().Str("test1", "v1").Send()
    myError()
    myError2()
}
```
2019-11-11 01:14:19 -08:00
CrazyMax 4502cc1942 Add TraceLevel (#158) 2019-11-04 11:39:22 -08:00
aca 43d05e8ddf hlog: add custom header handler (#197) 2019-11-04 10:14:00 -08:00
Nelz 5861452d64 enable adding raw JSON to an array (#145)
* enable adding JSON to an array

* do not forget the comment
2019-11-04 09:47:06 -08:00
hazimj 7592fcbe60 make TimeFormatUnixMicro var exportable (#189) 2019-10-24 17:02:51 -07:00
Veselkov Konstantin 2e41c37ac4 Fixed comment for documentations (#194) 2019-10-24 03:02:36 -07:00
hazimj 19e454b4c7 Add Unix time format for microseconds (#188) 2019-10-09 20:35:32 -07:00
Veselkov Konstantin 33a4561a07 remove golint errors (#187) 2019-10-04 07:31:06 -07:00
Tim Satke 06599535fa Bumped golang.org/x/tools (#183) 2019-08-28 14:58:12 -07:00
Charles Chan 61d1749124 Fix description in README for Global Settings (#176) 2019-08-11 07:03:49 +02:00
Stefan VanBuren b806a5ecbe Fix a few typos / clarify. (#169) 2019-07-19 18:10:43 +01:00
Zhang Sen a7f9fc2a17 simplify code of event.msg() (#165) 2019-07-19 12:35:57 +01:00
Christian Muehlhaeuser 42d101e9f7 Fixed code formatting and import order using goimports (#167) 2019-07-19 12:07:15 +01:00
i6du 77a1695358 add send function for convenience (#164) 2019-07-03 23:16:03 -07:00
wangyuehong 60d4b07b61 Add GetLevel method (#161) 2019-06-20 16:44:55 -07:00
IxDay 9938a23cba Fix JSON when object is first to be pushed (#154)
When pushing an object to the logger, and this object was the first
field added. Zerolog was outputting an invalid json blob, issuing an
extra comma before the object. This patch ensure that JSON is still valid
even if an object is pushed first to the logger.

Fixes #152
2019-06-04 23:48:09 -07:00
Vasiliy Faronov 1a2c7daec4 Fix misleading text about duplicate keys in JSON (#141)
Per RFC 8259 Section 4, behavior on duplicate keys is unspecified.

Fixes #140.
2019-05-25 18:51:33 -07:00
Olivier Poitrey ffd0e9625d Optimize basic sampler 2019-05-23 17:01:18 -07:00
Olivier Poitrey ad0401954a
Remove go 1.12 requirement 2019-05-23 11:44:28 -07:00
Olivier Poitrey acf3980132 console: handle timestamp in ms correctly + fix UTC 2019-04-25 12:44:49 -07:00
Olivier Poitrey 33f552ec3d Fix console write with missing level field 2019-04-25 12:12:24 -07:00
Olivier Poitrey 2a07580c27 Fix console writer when unix time stamp and/or no message field is used 2019-04-25 12:01:27 -07:00
Olivier Poitrey 3e85c4b21c Add a new time format for UNIX timestamp in milliseconds 2019-04-19 15:48:31 -07:00
Olivier Poitrey 509d727fba Add the Err function to ease the log errors. 2019-04-19 15:24:32 -07:00
Mike Camp 651d361cfe Add CallerWithSkipFrameCount to the Context (#98) (#135)
Add the ability to skip a specified number of stack frames
on a per context basis. Before this toe CallerSkipFrameCount
could only be set globally.
2019-03-04 16:41:18 -08:00
Soloman Weng 8e5449ab35 Allow using custom level field format (#136) 2019-03-01 16:08:23 -08:00
Olivier Poitrey 6d6350a511 Fix go1.12 test regression
Breakage is due to this change in go 1.12:

Tracebacks, runtime.Caller, and runtime.Callers no longer include compiler-generated initialization functions. Doing a traceback during the initialization of a global variable will now show a function named PKG.init.ializers.

Fix #137
2019-02-27 12:02:51 -08:00
mikeyrcamp 299ff038c1 Add support for customizing caller field format (#133) (#134) 2019-02-20 11:39:29 -08:00
Kevin McConnell 4daee2b758 Don't use faint text in colorized console output (#131)
The faint text style doesn't seem to be supported by all terminals,
which means the default console output loses most of its coloring on
them.

This commit changes the color scheme to more widely-supported colors.
This also matches how it looked in earlier versions of this library.
2019-02-07 07:45:02 -08:00
Olivier Poitrey aa55558e4c
Add support for stack trace extration of error fields (#35) 2019-01-03 11:04:23 -08:00
Ingmar Stein c482b20623 ConsoleWriter: fix race condition (#120)
Alternative approach to #118: fix the race condition by replacing the package-level customization settings with curried functions.
2018-12-07 09:59:01 -08:00
Ingmar Stein 7179aeef58 ConsoleWriter: reset buffer before returning it to the pool (#119)
The buffers put back into the pool should be equivalent to those generated by the `New` function.
2018-12-05 07:46:12 +00:00
Olivier Poitrey 8747b7b3a5 Add ErrorHandler global to allow handling of write errors 2018-11-20 10:56:21 -08:00
Olivier Poitrey 848482bc3d Fix "could not write" error missing carriage return (again) 2018-11-12 17:50:30 -08:00
Yongzheng Lai 7bcaa1a99e fix: console ts with json number (#115) 2018-11-12 00:50:17 -08:00
Olivier Poitrey 8e30c71369 Revert the wrapping of write errors
All errors generated by Go libraries on stderr won't be json encoded
anyway, so it does not make sense to have such a treatment for this one.
2018-11-08 14:49:44 -08:00