From 22f067d83b2321cc4b442e491eeb81bd98dc8fca Mon Sep 17 00:00:00 2001 From: re Date: Wed, 21 Dec 2022 15:59:06 +0300 Subject: [PATCH] fix repos --- .travis.yml | 2 +- README.md | 34 ++++++++++++++--------------- ci/go.mod | 2 +- doc.go | 28 ++++++++++++------------ example_basic_test.go | 6 ++--- example_custom_caller_test.go | 2 +- example_default_field_value_test.go | 2 +- example_function_test.go | 2 +- example_global_hook_test.go | 9 +++----- example_hook_test.go | 7 +++--- hook_test.go | 9 ++++---- hooks/syslog/README.md | 8 +++---- hooks/syslog/syslog.go | 3 ++- hooks/syslog/syslog_test.go | 4 ++-- hooks/test/test.go | 8 +------ hooks/test/test_test.go | 3 +-- hooks/writer/README.md | 4 ++-- hooks/writer/writer.go | 2 +- hooks/writer/writer_test.go | 2 +- internal/testutils/testutils.go | 2 +- json_formatter.go | 2 +- level_test.go | 2 +- logrus_test.go | 12 +++++----- writer_test.go | 2 +- 24 files changed, 73 insertions(+), 84 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1dbd5a..54d1db9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: go -go_import_path: github.com/sirupsen/logrus +go_import_path: git.internal/re/logrus git: depth: 1 env: diff --git a/README.md b/README.md index b042c89..11c5f6f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Logrus :walrus: [![Build Status](https://github.com/sirupsen/logrus/workflows/CI/badge.svg)](https://github.com/sirupsen/logrus/actions?query=workflow%3ACI) [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![Go Reference](https://pkg.go.dev/badge/github.com/sirupsen/logrus.svg)](https://pkg.go.dev/github.com/sirupsen/logrus) +# Logrus :walrus: [![Build Status](https://git.internal/re/logrus/workflows/CI/badge.svg)](https://git.internal/re/logrus/actions?query=workflow%3ACI) [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![Go Reference](https://pkg.go.dev/badge/git.internal/re/logrus.svg)](https://pkg.go.dev/git.internal/re/logrus) Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. @@ -28,12 +28,12 @@ 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 experienced problems with the upper-case variant, so the lower-case was decided. Everything using `logrus` will need to use the lower-case: -`github.com/sirupsen/logrus`. Any package that isn't, should be changed. +`git.internal/re/logrus`. Any package that isn't, should be changed. To fix Glide, see [these -comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). +comments](https://git.internal/re/logrus/issues/553#issuecomment-306591437). For an in-depth explanation of the casing issue, see [this -comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276). +comment](https://git.internal/re/logrus/issues/570#issuecomment-313933276). Nicely color-coded in development (when a TTY is attached, otherwise just plain text): @@ -109,7 +109,7 @@ go test -bench=.*CallerTracing 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 -the lower-case import: `github.com/sirupsen/logrus`. +the lower-case import: `git.internal/re/logrus`. #### Example @@ -119,7 +119,7 @@ The simplest way to use Logrus is simply the package-level exported logger: package main import ( - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" ) func main() { @@ -130,7 +130,7 @@ func main() { ``` 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.internal/re/logrus"` and you'll now have the flexibility of Logrus. You can customize it all you want: @@ -139,7 +139,7 @@ package main import ( "os" - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" ) func init() { @@ -190,7 +190,7 @@ package main import ( "os" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) // Create a new instance of the logger. You can have any number of instances. @@ -265,9 +265,9 @@ Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in ```go import ( - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "airbrake" - logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" + logrus_syslog "git.internal/re/logrus/hooks/syslog" "log/syslog" ) @@ -287,7 +287,7 @@ 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). -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://git.internal/re/logrus/wiki/Hooks) #### Level logging @@ -338,7 +338,7 @@ could do: ```go import ( - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" ) func init() { @@ -370,9 +370,9 @@ The built-in logging formatters are: * When colors are enabled, levels are truncated to 4 characters by default. To disable 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. - * 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/git.internal/re/logrus#TextFormatter). * `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/git.internal/re/logrus#JSONFormatter). Third party logging formatters: @@ -460,8 +460,8 @@ Logrus has a built in facility for asserting the presence of log messages. This ```go import( - "github.com/sirupsen/logrus" - "github.com/sirupsen/logrus/hooks/test" + "git.internal/re/logrus" + "git.internal/re/logrus/hooks/test" "github.com/stretchr/testify/assert" "testing" ) diff --git a/ci/go.mod b/ci/go.mod index e895e95..949224e 100644 --- a/ci/go.mod +++ b/ci/go.mod @@ -1,4 +1,4 @@ -module github.com/sirupsen/logrus/ci +module git.internal/re/logrus/ci go 1.15 diff --git a/doc.go b/doc.go index b4d32d2..201f19c 100644 --- a/doc.go +++ b/doc.go @@ -1,26 +1,26 @@ /* 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: - package main + package main - import ( - log "git.internal/re/logrus" - ) + import ( + log "git.internal/re/logrus" + ) - func main() { - log.WithFields(log.Fields{ - "animal": "walrus", - "number": 1, - "size": 10, - }).Info("A walrus appears") - } + func main() { + log.WithFields(log.Fields{ + "animal": "walrus", + "number": 1, + "size": 10, + }).Info("A walrus appears") + } Output: - 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 + +For a full guide visit https://git.internal/re/logrus */ package logrus diff --git a/example_basic_test.go b/example_basic_test.go index 9ff5655..11f6afb 100644 --- a/example_basic_test.go +++ b/example_basic_test.go @@ -3,13 +3,13 @@ package logrus_test import ( "os" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) func Example_basic() { - var log = logrus.New() + log := logrus.New() log.Formatter = new(logrus.JSONFormatter) - log.Formatter = new(logrus.TextFormatter) //default + log.Formatter = new(logrus.TextFormatter) // default log.Formatter.(*logrus.TextFormatter).DisableColors = true // remove colors log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output log.Level = logrus.TraceLevel diff --git a/example_custom_caller_test.go b/example_custom_caller_test.go index 6749eff..97d0296 100644 --- a/example_custom_caller_test.go +++ b/example_custom_caller_test.go @@ -6,7 +6,7 @@ import ( "runtime" "strings" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) func ExampleJSONFormatter_CallerPrettyfier() { diff --git a/example_default_field_value_test.go b/example_default_field_value_test.go index e7edd1a..64a3292 100644 --- a/example_default_field_value_test.go +++ b/example_default_field_value_test.go @@ -3,7 +3,7 @@ package logrus_test import ( "os" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) type DefaultFieldHook struct { diff --git a/example_function_test.go b/example_function_test.go index dda890d..0f2cb82 100644 --- a/example_function_test.go +++ b/example_function_test.go @@ -3,7 +3,7 @@ package logrus_test import ( "testing" - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" "github.com/stretchr/testify/assert" ) diff --git a/example_global_hook_test.go b/example_global_hook_test.go index ff7b255..ae9afde 100644 --- a/example_global_hook_test.go +++ b/example_global_hook_test.go @@ -3,15 +3,12 @@ package logrus_test import ( "os" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) -var ( - mystring string -) +var mystring string -type GlobalHook struct { -} +type GlobalHook struct{} func (h *GlobalHook) Levels() []logrus.Level { return logrus.AllLevels diff --git a/example_hook_test.go b/example_hook_test.go index dc0e69f..2c30618 100644 --- a/example_hook_test.go +++ b/example_hook_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package logrus_test @@ -6,13 +7,13 @@ import ( "log/syslog" "os" - "github.com/sirupsen/logrus" - slhooks "github.com/sirupsen/logrus/hooks/syslog" + "git.internal/re/logrus" + slhooks "git.internal/re/logrus/hooks/syslog" ) // An example on how to use a hook func Example_hook() { - var log = logrus.New() + log := logrus.New() log.Formatter = new(logrus.TextFormatter) // default log.Formatter.(*logrus.TextFormatter).DisableColors = true // remove colors log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output diff --git a/hook_test.go b/hook_test.go index a2becc8..9c440cf 100644 --- a/hook_test.go +++ b/hook_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/sirupsen/logrus" - "github.com/sirupsen/logrus/hooks/test" - . "github.com/sirupsen/logrus/internal/testutils" + . "git.internal/re/logrus" + "git.internal/re/logrus/hooks/test" + . "git.internal/re/logrus/internal/testutils" ) type TestHook struct { @@ -49,8 +49,7 @@ func TestHookFires(t *testing.T) { }) } -type ModifyHook struct { -} +type ModifyHook struct{} func (hook *ModifyHook) Fire(entry *Entry) error { entry.Data["wow"] = "whale" diff --git a/hooks/syslog/README.md b/hooks/syslog/README.md index 1bbc0f7..5edf2c4 100644 --- a/hooks/syslog/README.md +++ b/hooks/syslog/README.md @@ -5,8 +5,8 @@ ```go import ( "log/syslog" - "github.com/sirupsen/logrus" - lSyslog "github.com/sirupsen/logrus/hooks/syslog" + "git.internal/re/logrus" + lSyslog "git.internal/re/logrus/hooks/syslog" ) func main() { @@ -24,8 +24,8 @@ If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or " ```go import ( "log/syslog" - "github.com/sirupsen/logrus" - lSyslog "github.com/sirupsen/logrus/hooks/syslog" + "git.internal/re/logrus" + lSyslog "git.internal/re/logrus/hooks/syslog" ) func main() { diff --git a/hooks/syslog/syslog.go b/hooks/syslog/syslog.go index 02b8df3..fea582c 100644 --- a/hooks/syslog/syslog.go +++ b/hooks/syslog/syslog.go @@ -1,3 +1,4 @@ +//go:build !windows && !nacl && !plan9 // +build !windows,!nacl,!plan9 package syslog @@ -7,7 +8,7 @@ import ( "log/syslog" "os" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) // SyslogHook to send logs via syslog. diff --git a/hooks/syslog/syslog_test.go b/hooks/syslog/syslog_test.go index bec6efd..a5d38f6 100644 --- a/hooks/syslog/syslog_test.go +++ b/hooks/syslog/syslog_test.go @@ -1,3 +1,4 @@ +//go:build !windows && !nacl && !plan9 // +build !windows,!nacl,!plan9 package syslog @@ -6,13 +7,12 @@ import ( "log/syslog" "testing" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) func TestLocalhostAddAndPrint(t *testing.T) { log := logrus.New() hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") - if err != nil { t.Errorf("Unable to connect to local syslog.") } diff --git a/hooks/test/test.go b/hooks/test/test.go index b16d066..2bde6b7 100644 --- a/hooks/test/test.go +++ b/hooks/test/test.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "sync" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) // Hook is a hook designed for dealing with logs in test scenarios. @@ -20,32 +20,26 @@ type Hook struct { // NewGlobal installs a test hook for the global logger. func NewGlobal() *Hook { - hook := new(Hook) logrus.AddHook(hook) return hook - } // NewLocal installs a test hook for a given local logger. func NewLocal(logger *logrus.Logger) *Hook { - hook := new(Hook) logger.Hooks.Add(hook) return hook - } // NewNullLogger creates a discarding logger and installs the test hook. func NewNullLogger() (*logrus.Logger, *Hook) { - logger := logrus.New() logger.Out = ioutil.Discard return logger, NewLocal(logger) - } func (t *Hook) Fire(e *logrus.Entry) error { diff --git a/hooks/test/test_test.go b/hooks/test/test_test.go index 636bad5..981c0fc 100644 --- a/hooks/test/test_test.go +++ b/hooks/test/test_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" "github.com/stretchr/testify/assert" ) @@ -40,7 +40,6 @@ func TestAllHooks(t *testing.T) { } func TestLoggingWithHooksRace(t *testing.T) { - rand.Seed(time.Now().Unix()) unlocker := rand.Int() % 100 diff --git a/hooks/writer/README.md b/hooks/writer/README.md index 6967630..3f9fd69 100644 --- a/hooks/writer/README.md +++ b/hooks/writer/README.md @@ -14,8 +14,8 @@ import ( "io/ioutil" "os" - log "github.com/sirupsen/logrus" - "github.com/sirupsen/logrus/hooks/writer" + log "git.internal/re/logrus" + "git.internal/re/logrus/hooks/writer" ) func main() { diff --git a/hooks/writer/writer.go b/hooks/writer/writer.go index 1160c79..000321a 100644 --- a/hooks/writer/writer.go +++ b/hooks/writer/writer.go @@ -3,7 +3,7 @@ package writer import ( "io" - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" ) // Hook is a hook that writes logs of specified LogLevels to specified Writer diff --git a/hooks/writer/writer_test.go b/hooks/writer/writer_test.go index a30d3b0..3cb674c 100644 --- a/hooks/writer/writer_test.go +++ b/hooks/writer/writer_test.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "testing" - log "github.com/sirupsen/logrus" + log "git.internal/re/logrus" "github.com/stretchr/testify/assert" ) diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go index 6e3a620..f10b526 100644 --- a/internal/testutils/testutils.go +++ b/internal/testutils/testutils.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - . "github.com/sirupsen/logrus" + . "git.internal/re/logrus" "github.com/stretchr/testify/require" ) diff --git a/json_formatter.go b/json_formatter.go index c96dc56..8753f09 100644 --- a/json_formatter.go +++ b/json_formatter.go @@ -66,7 +66,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { switch v := v.(type) { case error: // Otherwise errors are ignored by `encoding/json` - // https://github.com/sirupsen/logrus/issues/137 + // https://git.internal/re/logrus/issues/137 data[k] = v.Error() default: data[k] = v diff --git a/level_test.go b/level_test.go index 78915c4..ee2da27 100644 --- a/level_test.go +++ b/level_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" "github.com/stretchr/testify/require" ) diff --git a/logrus_test.go b/logrus_test.go index 4edee28..0b440ff 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -15,8 +15,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/sirupsen/logrus" - . "github.com/sirupsen/logrus/internal/testutils" + . "git.internal/re/logrus" + . "git.internal/re/logrus/internal/testutils" ) // 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, "info", fields["level"]) assert.Equal(t, - "github.com/sirupsen/logrus_test.TestReportCallerWhenConfigured.func3", fields[FieldKeyFunc]) + "git.internal/re/logrus_test.TestReportCallerWhenConfigured.func3", fields[FieldKeyFunc]) }) LogAndAssertJSON(t, func(log *Logger) { @@ -328,7 +328,6 @@ func TestTimeOverrideMultipleLogs(t *testing.T) { } func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) { - var buffer bytes.Buffer var fields Fields @@ -356,7 +355,6 @@ func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) { assert.Equal(t, "omg it is!", fields["msg"]) assert.Equal(t, "eating raw fish", fields["context"]) assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry") - } func TestNestedLoggingReportsCorrectCaller(t *testing.T) { @@ -379,7 +377,7 @@ func TestNestedLoggingReportsCorrectCaller(t *testing.T) { assert.Equal(t, "looks delicious", fields["msg"]) assert.Equal(t, "eating raw fish", fields["context"]) assert.Equal(t, - "github.com/sirupsen/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) + "git.internal/re/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) cwd, err := os.Getwd() require.NoError(t, err) assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string))) @@ -410,7 +408,7 @@ func TestNestedLoggingReportsCorrectCaller(t *testing.T) { 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.Equal(t, - "github.com/sirupsen/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) + "git.internal/re/logrus_test.TestNestedLoggingReportsCorrectCaller", fields["func"]) require.NoError(t, err) assert.Equal(t, filepath.ToSlash(fmt.Sprintf("%s/logrus_test.go:%d", cwd, line-1)), filepath.ToSlash(fields["file"].(string))) diff --git a/writer_test.go b/writer_test.go index 5c34927..e7d1345 100644 --- a/writer_test.go +++ b/writer_test.go @@ -4,7 +4,7 @@ import ( "log" "net/http" - "github.com/sirupsen/logrus" + "git.internal/re/logrus" ) func ExampleLogger_Writer_httpServer() {