Commit Graph

34 Commits

Author SHA1 Message Date
Dave Clendenan eab1019f63 Merge branch 'master' of https://github.com/sirupsen/logrus 2017-08-30 15:39:09 -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
Antoine Grondin 9561fcd7d6 assertify changed behavior and consider float64 != int 2015-04-22 22:48:32 -04:00
Anton Tiurin f08673d24a [Race] Fix datarace in GetLevel
`std.Level` is protected by mutex in setter (SetLevel),
so it must be protected in geetter (GetLevel) too.

Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
2015-02-20 01:14:10 +03:00
Simon Eskildsen 844911ce07 test: remove deprecated #len calls 2015-01-20 20:38:13 -05:00
Simon Eskildsen 51fe59aca1 Merge pull request #92 from rasky/no-extra-quoting
Avoid extra quotes where not strictly necessary.
2014-12-18 10:52:14 -05:00
Giovanni Bajo e5c1364122 Fix test to adjust for missing quotes 2014-12-18 15:14:24 +01:00
Antoine Grondin 2835e150d9 fixes #88 2014-12-09 21:57:50 -05:00
Antoine Grondin 62b915c008 regression test for issue #88 2014-12-09 21:53:14 -05:00
Antoine Grondin 3737b3267e logrus: remove test for dbg alias in ParseLevel. 2014-09-24 23:23:01 -04:00
Simon Eskildsen 4617ccb653 Merge pull request #62 from mohae/setloglevel
added support for setting log level using strings: SetLogLevel()
2014-09-24 23:09:09 -04:00
Antoine Grondin dc01f6d597 add regression for basic fields being incorrectly prefixed 2014-09-21 13:16:35 -04:00
Joel Scoble 4e6e671281 add ParseLevel to get Level from string 2014-09-17 20:08:23 -05:00
Simon Eskildsen 40069a98d6 entry: break out time, level and message from data 2014-07-26 21:34:29 -04:00
Simon Eskildsen cd8fc638cc levels: add string helper 2014-07-26 21:02:08 -04:00
Shuhao Wu 7a3a90cb3d Added test 2014-06-09 11:54:10 -04:00
Simon Eskildsen f8afa65d86 test: remove temporary benchmarks 2014-05-03 20:31:11 -04:00
Simon Eskildsen d85ac80aa9 entry: log with spaces between all operands on *ln #25 2014-05-03 20:20:07 -04:00
Anthony Bishopric 9f6da0e77c Defer formatting of log values in Levelf(), Levelln()
The Level() family of log methods defer formatting of log
values until it is confident that the log level needs them.
This change allows that deferral to happen at the Levelf()
and Levelln() levels too.

This commit also adds benchmarks to demonstrate the improved
performance of these functions
2014-03-25 14:54:31 -07:00
Simon Eskildsen 53371e3664 Add features from README 2014-03-10 19:22:08 -04:00