Commit Graph

68 Commits

Author SHA1 Message Date
Ash McKenzie 80d649c2d1
Fix go-staticcheck S1021 issues 2023-06-03 13:34:35 +10:00
David Bariod ac6e35b4c2 fix for entry data field race condition 2021-02-16 10:31:51 +01:00
Edward Muller 46015a925f
test the error to ensure there isn't an unexpected error in the test 2019-10-13 17:48:58 -07:00
Christian Muehlhaeuser d4257626ad
Fixed ineffectual assignment in test
Don't assign l if it's not being checked/used afterwards.
2019-07-20 03:27:21 +02:00
georlav b9d451406d fix ReportCaller race condition 2019-03-04 20:58:21 +02:00
David Bariod ffec2f2e0a Add a CallerPrettyfier callback to the text formatter 2019-02-27 13:35:45 +01:00
David Bariod 5e9b246bea Add a CallerPrettyfier callback to the json formatter 2019-02-27 13:02:20 +01:00
noushavandijk 4f5fd631f1 Fix infinite recursion on unknown Level.String()
Using `%q` in the error string causes `MarshalText` to recurse (by calling String()).
2019-02-20 09:22:53 -08: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 bd9534b799 Test Log 2019-01-02 14:59:36 -05:00
Lisa Ugray e8fd0ba609 Remove sensitivity to file line changes 2019-01-02 14:58:51 -05:00
David Bariod ff695daa36 Implement TextUnmarshaller interface for Level type
Since the implementation of the TextMarshaller interface
we could not unmarshal previously json marshalled Level value.
Fixes #873
2018-12-26 17:43:14 +01:00
David Bariod d10c2f9e3c fix panic in text formatter
The panic was caused to a nil pointer access when report
caller was activated with output coloring disabled

Fixes #852
2018-10-31 07:08:09 +01:00
David Bariod 566a5f6908
Merge pull request #845 from yanana/make-level-implement-text-unmarshaler
Make logrus.Level implement encoding.TextUnmarshaler
2018-10-29 07:08:39 +01:00
David Bariod 5a78c38d0e make file name comparison os independant 2018-10-28 18:12:32 +01:00
David Bariod d2654b752f add file and line number in output when report caller is enabled 2018-10-28 17:39:39 +01:00
David Bariod fa01b53097 move test functions and test utils functions in their own package 2018-10-28 14:22:33 +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
Shun Yanaura 5c1f2cd52c Make logrus.Level implement encoding.TextUnmarshaler 2018-10-22 04:20:01 +09:00
Loren Osborn ed3ffa0190 PR#844: Added Trace to TestLogLevelEnabled() (requested by @dgsb) 2018-10-19 09:15:13 -07:00
Loren Osborn b54cafe5ce Addresses @stevvooe's backward compatibility concerns. 2018-10-18 10:12:27 -07:00
Giedrius Dubinskas c7a33dc5de Add Trace level logging 2018-10-17 19:12:50 -07: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
betrok 13d10d8d89 return old hooks from RelplaceHooks 2018-08-26 14:40:51 +03:00
betrok 7a0120e2c6 logger.ReplaceHooks 2018-08-22 12:10:05 +03: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
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
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
Michael Haines 828a649ef2 rename fieldLogger to entry 2018-02-05 12:52:11 -07:00
Michael Haines efbfdb5f09 Add failing test for using a FieldLogger with hooks inside goroutines 2018-02-05 12:42:00 -07:00
Dave Clendenan b1db1b9c67 regex assertion rather than literal, for github path 2017-08-02 17:28:13 -07: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
David Glasser 1fccefa2f4 Add Writer and WriterLevel to Entry
This lets you do things like:

    cmd := exec.Command("command")
    stdout := logrus.WithField("fd", "stdout").Writer()
    defer stdout.Close()
    stderr := logrus.WithField("fd", "stderr").Writer()
    defer stderr.Close()
    cmd.Stdout = stdout
    cmd.Stderr = stderr
2017-03-06 16:24:57 -08: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 306956c385 tweak timing tests to handle slower VMs and older GoLang 2016-12-01 11:12:44 -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 a5c845c224 responses to review comments
- empty string as marker for failure to discover calling function
 - tighten up logger usage - don't rely on std logger internally

Also fix ordering of expected/got in logrus_test.go to ensure correct
output form test failures.
2016-11-30 14:07:10 -08:00
Dave Clendenan 05a8f4db95 fix test description 2016-11-30 10:47:03 -08:00
Dave Clendenan 348bace269 doc updates, and relabel ReportMethod
in the Logrus context it's the caller, so use that internally.  Label
stays as 'method' since in the context of the log event that seems more
correct.
2016-11-29 09:35:34 -08:00
Dave Clendenan 93af604ba7 First cut at adding calling method
If log.SetReportMethod(true) then method=PACKAGE.FUNCTION will be added
as a field to log lines.
eg: time="2016-11-25T19:04:43-08:00" level=info method=main msg="log
testing"

TODO: documentation, examples
2016-11-25 19:02:56 -08:00
Simon Eskildsen 897f3dddf1 Rename LogrusLogger interface to FieldLogger 2016-03-17 14:07:00 +00:00
Simon Eskildsen bb78923f27 Merge pull request #320 from little-arhat/feature-logrus-interface
Add LogrusLogger interface for Entry and Logger
2016-03-17 10:01:39 -04:00
Rickard Dybeck 03ba213b8a Make ParseLevel case-insensitive
Coming from an environment where loglevels are always specified in
uppercase, having ParseLevel be case-insensitive is a nice to have.
2016-02-16 16:27:38 +01:00
Roma Sokolov 1196d67b47 Add LogrusLogger interface for Entry and Logger
This make it possible for client code to accept either Logger or Entry.
For example, utility function may accept logger object to inform fatal
errors and it is job of the calling code to provide either generic
top-level logger, or request-bound Entry created using .WithFields.

(fixes #308)
2016-02-02 17:38:49 +00:00
Ronny López 6094714616 Run tests with -race 2016-01-23 11:18:45 +01:00
Simon Eskildsen 4197a1bbd5 Revert "TextMarshaler and TextUnmarshaler implementation for Level" 2015-10-05 07:45:58 -04:00
Maksim Naumov 277d0cb562 `TextMarshaler` and `TextUnmarshaler` implementation for `Level` 2015-09-12 22:41:06 +02:00