Commit Graph

106 Commits

Author SHA1 Message Date
Alex S 86a84a9d18 Get right logrus package name 2020-03-02 21:47:38 +08:00
Mark Phelps 77ab282a06
Merge pull request #1047 from lwsanty/fix-race-conditions-on-entry
fix race conditions on entry
2020-02-26 18:44:58 -05:00
Sébastien Lavoie 24566a3fc4
Merge pull request #924 from bunyk/master
Add hook to send logs to custom writer #678
2020-02-26 17:31:00 -05:00
Taylor Wrobel bcc146f96b Fix entity data bleed when using WithContext and WithTime
Creates a copy of the data map when using WithContext to create a
child entity.  Without this, the data map of the parent entitiy,
which is exposed in the entity struct, is shared between a parent
and all children instances.

This can create bugs of shared or overwritten data when a parent
entity is used to make children in differing contexts, and behaves
differently than `WithField` and its diritivites which does make
a copy of the data.

Additionally implements the same logic for WithTime, for API
consistency in behavior.
2019-11-27 20:20:42 -08:00
David Bariod b77b626665 run golangci-lint on travis 2019-10-25 14:49:48 +02:00
lwsanty c7278b2d7a fix race conditions on entry
closes #1046
2019-10-23 20:55:57 +03:00
Edward Muller 60320cbc2c
return early
This makes it easier to read / understand and is more idiomatic.
2019-09-05 16:09:16 -07:00
tbunyk 8b0b8a88f2 Merge remote-tracking branch 'upstream/master' 2019-09-03 15:29:19 +03:00
Haoran Xu 38bc297a3d return new entry for Entry.WithContext 2019-03-29 14:04:26 +08:00
tbunyk c88f8de1fe Add Bytes() method to Entry, and use it to avoid double type cast 2019-03-18 16:07:31 +02:00
Adam Renberg Tamm 68e41f673a Add WithContext 2019-03-11 15:38:19 +01:00
David Bariod cf1b9fd15e fix sync.Once usage instead of adding a mutex lock 2019-03-06 14:08:02 +01:00
georlav b9d451406d fix ReportCaller race condition 2019-03-04 20:58:21 +02:00
David Bariod 5e9b246bea Add a CallerPrettyfier callback to the json formatter 2019-02-27 13:02:20 +01:00
Gavin Cabbage c4e4882020 prevent string formatting in Entry.Logf when log level is not enabled 2019-02-06 14:51:33 -05:00
Richard Poirier e1e72e9de9
Merge pull request #863 from lugray/generic_log
Add Generic Log functions with level via argument
2019-01-02 14:40:11 -08:00
Lisa Ugray a6668e7a60 Add Generic Log functions with level via argument 2018-12-20 15:49:25 -05:00
David Bariod 9abefb94aa do not clear error formatting informative field 2018-12-14 17:01:34 +01:00
Maxim Sukharev 08e8d6501d Skip func pointer type value in fields
Before there was introduced a fix for JSONFormatter when func type value
passed as Field. This commit does the same but for pointer to func.

Ref:
https://github.com/sirupsen/logrus/issues/642
https://github.com/sirupsen/logrus/pull/832
2018-12-05 19:14:19 +01:00
David Bariod ec57031db1 store a runtime.Frame in Entry instead of the caller function name 2018-10-28 14:21:49 +01:00
David Bariod 975c406ddb Use a sync.Once to init the reportCaller data 2018-10-27 15:21:30 +02:00
David Bariod 64d5b7e66c Merge branch 'master' into caller_feature 2018-10-27 15:10:52 +02:00
Maxim Korolyov ef9d84e9b3 Added trace log level. 2018-10-17 19:42:01 -07:00
drampull 4981d8161c Added TRACE level logging. 2018-10-17 18:22:00 -07:00
Albert Salim 2be620216a Add option to panic in `test.NewNullLogger` to allow testing of
calls to `Fatal*`

See #813
2018-10-06 18:08:19 +08:00
David Bariod 7b467df697 Skip func type value in fields.
We skip those unprintable fields and an error field
instead of dropping the whole trace.

Fixes #642
2018-09-30 22:51:02 +02:00
William Huang 88eb166d31
Fix spelling in Entry.Buffer comment 2018-09-06 21:11:16 -05:00
Logan HAUSPIE 90bf2e7f39
feat(LogLevel): taking in account code review from David Bariod 2018-08-27 00:16:06 +02:00
Logan HAUSPIE 0ab534bf6c
Merge remote-tracking branch 'upstream/master' 2018-08-26 23:36:08 +02:00
David Bariod c108f5553c Merge branch 'field-logger-with-hooks-race' of git://github.com/thundercat1/logrus into master 2018-07-23 13:53:07 +02:00
David Bariod 3e01752db0 Merge branch 'moriyoshi/refix-707' of git://github.com/moriyoshi/logrus into fix_firehooks 2018-07-21 09:00:01 +02:00
Simon Brisson 725f3be199 Adds WithTime to Logger and Entry types, as well as a pure module-level function. 2018-07-12 13:25:17 -04:00
Simon Brisson 52b92f5b89 Allows overriding Entry.Time. 2018-07-03 11:38:02 -04:00
Logan HAUSPIE 4225d694ba
feat: new methods to check enabled log level
Adding 6 methods on 'exported', 'logger' and 'entry':
- IsDebugEnabled() bool
- IsInfoEnabled() bool
- IsWarnEnabled() bool
- IsErrorEnabled() bool
- IsFatalEnabled() bool
- IsPanicEnabled() bool

Replace duplicated 'if logger.level() >= XxxxLevel' by a call to the new methods in 'logger' and 'entry'

Closes #761
2018-06-06 22:45:35 +02:00
Moriyoshi Koizumi 070c81def3 Revert the change introduced in #707 and do the proper fix. Fixes #729 2018-05-30 09:50:59 +00:00
Dave Clendenan c74e39f432
Merge branch 'master' into master 2018-03-08 15:53:25 -08:00
earlzo 1893e9a3ed Fixed: comment 2018-02-20 16:28:12 +08:00
Jay Ching Lim be569094e9
Make fireHooks() method receive a copy of Entry structure to avoid race conditions
Signed-off-by: Jay Ching Lim <imjching@users.noreply.github.com>
2018-02-12 17:26:48 -05:00
Michael Haines eeb653535c Lock mutex before formatting to avoid race 2018-02-05 12:44:11 -07:00
Maurício Linhares 977e03308a
Fix deadlock on panics at Entry.log
When calling Entry.log a panic inside some of the
locking blocks could cause the whole logger to deadlock.

One of the ways this could happen is for a hook to cause
a panic, when this happens the lock is never unlocked and
the library deadlocks, causing the code that is calling
it to deadlock as well.

This changes how locking happens with unlocks at defer
blocks so even if a panic happens somewhere along the log
call the library will still unlock and continue to function.
2018-01-22 10:52:46 -05:00
Dave Clendenan 40f571805d Merge branch 'master' of https://github.com/dclendenan/logrus 2017-08-30 15:43:36 -07:00
Dave Clendenan eab1019f63 Merge branch 'master' of https://github.com/sirupsen/logrus 2017-08-30 15:39:09 -07:00
Aditya Mukerjee c830992a61 Take lock on mutex when firing hooks 2017-08-17 15:22:06 +01:00
Dave Clendenan 3cb9e18ef9 test updates
- add tests for callers accessed directly or via function pointer
  (results are unchanged)
- undo unwanted capitalization/export in previous commit
2017-08-02 17:21:18 -07:00
Dave Clendenan 7d48cb786e Merge branch 'master' of https://github.com/sirupsen/logrus
Conflicts:
	alt_exit_test.go
	formatter.go
	json_formatter.go
2017-08-02 13:18:39 -07:00
DmitriyMV 95002bc717 Improve logrus.Entry.Level documentation 2017-07-14 15:04:50 +03:00
DmitriyMV 3bcb09397d This commit fixes data race using atomics. We switch type of level from uint8 to uint32 but due memory alignment on most platforms it will not result in any additional memory. 2017-03-23 19:13:49 +03:00
Dave Clendenan 88dd8df1f8 responses to code review
- field rename to be more properly generic
 - drop rewrite of main.main
2016-12-06 12:53:21 -08:00
Dave Clendenan f08011a10f merge upstream, add tests, full method context
- added benchmarks, and assertions for timeliness
- replaced regex usage in package-name handling with a straight
  comparison to a cached value
- log the fullly-qualified method name, to remove ambiguity
    eg: github.com/fflintstone/yabba.dabba.doo
- clean up possibly-unsafe assumptions about using the standard logger,
  remove global lookup function to enforce safe usage
2016-12-01 10:23:00 -08:00
Dave Clendenan 65f3af38f7 simplify hasCaller check 2016-11-30 15:15:38 -08:00