rename module

This commit is contained in:
2026-03-29 17:46:59 +03:00
parent dd1b4c2e81
commit fec218f549
23 changed files with 105 additions and 91 deletions
+46 -39
View File
@@ -28,7 +28,7 @@ import Logrus as both upper- and lower-case. Due to the Go package environment,
this caused issues in the community and we needed a standard. Some environments this caused issues in the community and we needed a standard. Some environments
experienced problems with the upper-case variant, so the lower-case was decided. experienced problems with the upper-case variant, so the lower-case was decided.
Everything using `logrus` will need to use the lower-case: Everything using `logrus` will need to use the lower-case:
`github.com/sirupsen/logrus`. Any package that isn't, should be changed. `git.corp.kornet35.ru/gopkg/logrus`. Any package that isn't, should be changed.
To fix Glide, see [these To fix Glide, see [these
comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437).
@@ -72,6 +72,7 @@ time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperatu
time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
``` ```
To ensure this behaviour even if a TTY is attached, set your formatter as follows: To ensure this behaviour even if a TTY is attached, set your formatter as follows:
```go ```go
@@ -84,32 +85,40 @@ To ensure this behaviour even if a TTY is attached, set your formatter as follow
#### Logging Method Name #### Logging Method Name
If you wish to add the calling method as a field, instruct the logger via: If you wish to add the calling method as a field, instruct the logger via:
```go ```go
log.SetReportCaller(true) log.SetReportCaller(true)
``` ```
This adds the caller as 'method' like so: This adds the caller as 'method' like so:
```json ```json
{"animal":"penguin","level":"fatal","method":"github.com/sirupsen/arcticcreatures.migrate","msg":"a penguin swims by", {
"time":"2014-03-10 19:57:38.562543129 -0400 EDT"} "animal": "penguin",
"level": "fatal",
"method": "github.com/sirupsen/arcticcreatures.migrate",
"msg": "a penguin swims by",
"time": "2014-03-10 19:57:38.562543129 -0400 EDT"
}
``` ```
```text ```text
time="2015-03-26T01:27:38-04:00" level=fatal method=github.com/sirupsen/arcticcreatures.migrate msg="a penguin swims by" animal=penguin time="2015-03-26T01:27:38-04:00" level=fatal method=github.com/sirupsen/arcticcreatures.migrate msg="a penguin swims by" animal=penguin
``` ```
Note that this does add measurable overhead - the cost will depend on the version of Go, but is Note that this does add measurable overhead - the cost will depend on the version of Go, but is
between 20 and 40% in recent tests with 1.6 and 1.7. You can validate this in your between 20 and 40% in recent tests with 1.6 and 1.7. You can validate this in your
environment via benchmarks: environment via benchmarks:
``` ```
go test -bench=.*CallerTracing go test -bench=.*CallerTracing
``` ```
#### Case-sensitivity #### Case-sensitivity
The organization's name was changed to lower-case--and this will not be changed The organization's name was changed to lower-case--and this will not be changed
back. If you are getting import conflicts due to case sensitivity, please use back. If you are getting import conflicts due to case sensitivity, please use
the lower-case import: `github.com/sirupsen/logrus`. the lower-case import: `git.corp.kornet35.ru/gopkg/logrus`.
#### Example #### Example
@@ -119,7 +128,7 @@ The simplest way to use Logrus is simply the package-level exported logger:
package main package main
import ( import (
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
) )
func main() { func main() {
@@ -130,7 +139,7 @@ func main() {
``` ```
Note that it's completely api-compatible with the stdlib logger, so you can Note that it's completely api-compatible with the stdlib logger, so you can
replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"` replace your `log` imports everywhere with `log "git.corp.kornet35.ru/gopkg/logrus"`
and you'll now have the flexibility of Logrus. You can customize it all you and you'll now have the flexibility of Logrus. You can customize it all you
want: want:
@@ -139,7 +148,7 @@ package main
import ( import (
"os" "os"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
) )
func init() { func init() {
@@ -190,7 +199,7 @@ package main
import ( import (
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
// Create a new instance of the logger. You can have any number of instances. // Create a new instance of the logger. You can have any number of instances.
@@ -265,9 +274,9 @@ Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
```go ```go
import ( import (
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
"gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "airbrake" "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "airbrake"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" logrus_syslog "git.corp.kornet35.ru/gopkg/logrus/hooks/syslog"
"log/syslog" "log/syslog"
) )
@@ -285,11 +294,11 @@ func init() {
} }
} }
``` ```
Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md). Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md).
A list of currently known service hooks can be found in this wiki [page](https://github.com/sirupsen/logrus/wiki/Hooks) A list of currently known service hooks can be found in this wiki [page](https://github.com/sirupsen/logrus/wiki/Hooks)
#### Level logging #### Level logging
Logrus has seven logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic. Logrus has seven logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic.
@@ -340,7 +349,7 @@ could do:
```go ```go
import ( import (
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
) )
func init() { func init() {
@@ -363,29 +372,29 @@ Splunk or Logstash.
The built-in logging formatters are: The built-in logging formatters are:
* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise - `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
without colors. without colors.
* *Note:* to force colored output when there is no TTY, set the `ForceColors` - _Note:_ to force colored output when there is no TTY, set the `ForceColors`
field to `true`. To force no colored output even if there is a TTY set the field to `true`. To force no colored output even if there is a TTY set the
`DisableColors` field to `true`. For Windows, see `DisableColors` field to `true`. For Windows, see
[github.com/mattn/go-colorable](https://github.com/mattn/go-colorable). [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable).
* When colors are enabled, levels are truncated to 4 characters by default. To disable - When colors are enabled, levels are truncated to 4 characters by default. To disable
truncation set the `DisableLevelTruncation` field to `true`. truncation set the `DisableLevelTruncation` field to `true`.
* When outputting to a TTY, it's often helpful to visually scan down a column where all the levels are the same width. Setting the `PadLevelText` field to `true` enables this behavior, by adding padding to the level text. - When outputting to a TTY, it's often helpful to visually scan down a column where all the levels are the same width. Setting the `PadLevelText` field to `true` enables this behavior, by adding padding to the level text.
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter). - All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter).
* `logrus.JSONFormatter`. Logs fields as JSON. - `logrus.JSONFormatter`. Logs fields as JSON.
* All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter). - All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter).
Third party logging formatters: Third party logging formatters:
* [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can be parsed by Kubernetes and Google Container Engine. - [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can be parsed by Kubernetes and Google Container Engine.
* [`GELF`](https://github.com/fabienm/go-logrus-formatters). Formats entries so they comply to Graylog's [GELF 1.1 specification](http://docs.graylog.org/en/2.4/pages/gelf.html). - [`GELF`](https://github.com/fabienm/go-logrus-formatters). Formats entries so they comply to Graylog's [GELF 1.1 specification](http://docs.graylog.org/en/2.4/pages/gelf.html).
* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. - [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events.
* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. - [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the Power of Zalgo. - [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the Power of Zalgo.
* [`nested-logrus-formatter`](https://github.com/antonfisher/nested-logrus-formatter). Converts logrus fields to a nested structure. - [`nested-logrus-formatter`](https://github.com/antonfisher/nested-logrus-formatter). Converts logrus fields to a nested structure.
* [`powerful-logrus-formatter`](https://github.com/zput/zxcTool). get fileName, log's line number and the latest function's name when print log; Sava log to files. - [`powerful-logrus-formatter`](https://github.com/zput/zxcTool). get fileName, log's line number and the latest function's name when print log; Sava log to files.
* [`caption-json-formatter`](https://github.com/nolleh/caption_json_formatter). logrus's message json formatter with human-readable caption added. - [`caption-json-formatter`](https://github.com/nolleh/caption_json_formatter). logrus's message json formatter with human-readable caption added.
You can define your formatter by implementing the `Formatter` interface, You can define your formatter by implementing the `Formatter` interface,
requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
@@ -449,21 +458,21 @@ entries. It should not be a feature of the application-level logger.
#### Tools #### Tools
| Tool | Description | | Tool | Description |
| ---- | ----------- | | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will be generated with different configs in different environments.| | [Logrus Mate](https://github.com/gogap/logrus_mate) | Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will be generated with different configs in different environments. |
|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) | | [Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper) | An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) |
#### Testing #### Testing
Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides: Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:
* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just adds the `test` hook - decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just adds the `test` hook
* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any): - a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):
```go ```go
import( import(
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
"github.com/sirupsen/logrus/hooks/test" "git.corp.kornet35.ru/gopkg/logrus/hooks/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing" "testing"
) )
@@ -504,12 +513,10 @@ If you are sure such locking is not needed, you can call logger.SetNoLock() to d
Situation when locking is not needed includes: Situation when locking is not needed includes:
* You have no hooks registered, or hooks calling is already thread-safe. - You have no hooks registered, or hooks calling is already thread-safe.
* Writing to logger.Out is already thread-safe, for example: * Writing to logger.Out is already thread-safe, for example:
1. logger.Out is protected by locks.
1) logger.Out is protected by locks.
2) logger.Out is an os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allows multi-thread/multi-process writing) 2) logger.Out is an os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allows multi-thread/multi-process writing)
(Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/) (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/)
+1 -1
View File
@@ -1,4 +1,4 @@
module github.com/sirupsen/logrus/ci module git.corp.kornet35.ru/gopkg/logrus/ci
go 1.15 go 1.15
+7 -3
View File
@@ -1,13 +1,12 @@
/* /*
Package logrus is a structured logger for Go, completely API compatible with the standard library logger. Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
The simplest way to use Logrus is simply the package-level exported logger: The simplest way to use Logrus is simply the package-level exported logger:
package main package main
import ( import (
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
) )
func main() { func main() {
@@ -19,8 +18,13 @@ The simplest way to use Logrus is simply the package-level exported logger:
} }
Output: Output:
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
For a full guide visit https://github.com/sirupsen/logrus time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
For a full guide visit https://git.corp.kornet35.ru/gopkg/logrus
*/ */
package logrus package logrus
+1 -1
View File
@@ -3,7 +3,7 @@ package logrus_test
import ( import (
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
func Example_basic() { func Example_basic() {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
func ExampleJSONFormatter_CallerPrettyfier() { func ExampleJSONFormatter_CallerPrettyfier() {
+1 -1
View File
@@ -3,7 +3,7 @@ package logrus_test
import ( import (
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
type DefaultFieldHook struct { type DefaultFieldHook struct {
+1 -1
View File
@@ -3,7 +3,7 @@ package logrus_test
import ( import (
"testing" "testing"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+1 -1
View File
@@ -3,7 +3,7 @@ package logrus_test
import ( import (
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
var ( var (
+3 -2
View File
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows // +build !windows
package logrus_test package logrus_test
@@ -6,8 +7,8 @@ import (
"log/syslog" "log/syslog"
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
slhooks "github.com/sirupsen/logrus/hooks/syslog" slhooks "git.corp.kornet35.ru/gopkg/logrus/hooks/syslog"
) )
// An example on how to use a hook // An example on how to use a hook
+1 -1
View File
@@ -1,4 +1,4 @@
module github.com/sirupsen/logrus module git.corp.kornet35.ru/gopkg/logrus
require ( require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
+3 -3
View File
@@ -10,9 +10,9 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
. "github.com/sirupsen/logrus" . "git.corp.kornet35.ru/gopkg/logrus"
"github.com/sirupsen/logrus/hooks/test" "git.corp.kornet35.ru/gopkg/logrus/hooks/test"
. "github.com/sirupsen/logrus/internal/testutils" . "git.corp.kornet35.ru/gopkg/logrus/internal/testutils"
) )
type TestHook struct { type TestHook struct {
+6 -6
View File
@@ -5,8 +5,8 @@
```go ```go
import ( import (
"log/syslog" "log/syslog"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
lSyslog "github.com/sirupsen/logrus/hooks/syslog" lSyslog "git.corp.kornet35.ru/gopkg/logrus/hooks/syslog"
) )
func main() { func main() {
@@ -24,8 +24,8 @@ If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "
```go ```go
import ( import (
"log/syslog" "log/syslog"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
lSyslog "github.com/sirupsen/logrus/hooks/syslog" lSyslog "git.corp.kornet35.ru/gopkg/logrus/hooks/syslog"
) )
func main() { func main() {
@@ -54,8 +54,8 @@ package main
import ( import (
"log/syslog" "log/syslog"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" logrus_syslog "git.corp.kornet35.ru/gopkg/logrus/hooks/syslog"
) )
type customHook struct { type customHook struct {
+2 -1
View File
@@ -1,3 +1,4 @@
//go:build !windows && !nacl && !plan9
// +build !windows,!nacl,!plan9 // +build !windows,!nacl,!plan9
package syslog package syslog
@@ -7,7 +8,7 @@ import (
"log/syslog" "log/syslog"
"os" "os"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
// SyslogHook to send logs via syslog. // SyslogHook to send logs via syslog.
+2 -1
View File
@@ -1,3 +1,4 @@
//go:build !windows && !nacl && !plan9
// +build !windows,!nacl,!plan9 // +build !windows,!nacl,!plan9
package syslog package syslog
@@ -6,7 +7,7 @@ import (
"log/syslog" "log/syslog"
"testing" "testing"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
func TestLocalhostAddAndPrint(t *testing.T) { func TestLocalhostAddAndPrint(t *testing.T) {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"sync" "sync"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
) )
// Hook is a hook designed for dealing with logs in test scenarios. // Hook is a hook designed for dealing with logs in test scenarios.
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+2 -2
View File
@@ -14,8 +14,8 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
"github.com/sirupsen/logrus/hooks/writer" "git.corp.kornet35.ru/gopkg/logrus/hooks/writer"
) )
func main() { func main() {
+1 -1
View File
@@ -3,7 +3,7 @@ package writer
import ( import (
"io" "io"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
) )
// Hook is a hook that writes logs of specified LogLevels to specified Writer // Hook is a hook that writes logs of specified LogLevels to specified Writer
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
log "github.com/sirupsen/logrus" log "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"strings" "strings"
"testing" "testing"
. "github.com/sirupsen/logrus" . "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"testing" "testing"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
+5 -5
View File
@@ -15,8 +15,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
. "github.com/sirupsen/logrus" . "git.corp.kornet35.ru/gopkg/logrus"
. "github.com/sirupsen/logrus/internal/testutils" . "git.corp.kornet35.ru/gopkg/logrus/internal/testutils"
) )
// TestReportCaller verifies that when ReportCaller is set, the 'func' field // TestReportCaller verifies that when ReportCaller is set, the 'func' field
@@ -40,7 +40,7 @@ func TestReportCallerWhenConfigured(t *testing.T) {
assert.Equal(t, "testWithCaller", fields["msg"]) assert.Equal(t, "testWithCaller", fields["msg"])
assert.Equal(t, "info", fields["level"]) assert.Equal(t, "info", fields["level"])
assert.Equal(t, assert.Equal(t,
"github.com/sirupsen/logrus_test.TestReportCallerWhenConfigured.func3", fields[FieldKeyFunc]) "git.corp.kornet35.ru/gopkg/logrus_test.TestReportCallerWhenConfigured.func3", fields[FieldKeyFunc])
}) })
LogAndAssertJSON(t, func(log *Logger) { LogAndAssertJSON(t, func(log *Logger) {
@@ -379,7 +379,7 @@ func TestNestedLoggingReportsCorrectCaller(t *testing.T) {
assert.Equal(t, "looks delicious", fields["msg"]) assert.Equal(t, "looks delicious", fields["msg"])
assert.Equal(t, "eating raw fish", fields["context"]) assert.Equal(t, "eating raw fish", fields["context"])
assert.Equal(t, assert.Equal(t,
"github.com/sirupsen/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) "git.corp.kornet35.ru/gopkg/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"])
cwd, err := os.Getwd() cwd, err := os.Getwd()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string))) assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string)))
@@ -410,7 +410,7 @@ func TestNestedLoggingReportsCorrectCaller(t *testing.T) {
assert.Equal(t, "The hardest workin' man in show business", fields["msg"]) assert.Equal(t, "The hardest workin' man in show business", fields["msg"])
assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry") assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry")
assert.Equal(t, assert.Equal(t,
"github.com/sirupsen/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) "git.corp.kornet35.ru/gopkg/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"])
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string))) assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string)))
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/sirupsen/logrus" "git.corp.kornet35.ru/gopkg/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )