Compare commits
2 commits
master
...
1-add-a-tr
Author | SHA1 | Date | |
---|---|---|---|
bbe1cb1d29 | |||
13cf00aba7 |
7 changed files with 1574 additions and 3075 deletions
4603
.golangci.yml
4603
.golangci.yml
File diff suppressed because it is too large
Load diff
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,19 +1,8 @@
|
|||
# go/logging Changelog
|
||||
# go/logging
|
||||
|
||||
## Unreleased
|
||||
|
||||
## v0.5.0 (2025-05-07)
|
||||
|
||||
- The default formatter now prints timestamps with microseconds
|
||||
- Fix the use of syslog on darwin
|
||||
|
||||
## v0.4.1 (2022-06-03)
|
||||
|
||||
- Ensure all backends implement the interface `BACKEND`.
|
||||
- `FileBackend` and `SyslogBackend` always returned errors for `Write`
|
||||
operations.
|
||||
|
||||
## v0.4.0 (2022-05-31)
|
||||
## v0.4.0 (2020-05-17)
|
||||
|
||||
- Add three new log levels: `Trace`, `Notice` and `Alert` with the following
|
||||
order: `Trace`, `Debug`, `Info`, `Notice`, `Warning`, `Error`, `Critical`,
|
||||
|
|
4
go.mod
4
go.mod
|
@ -1,5 +1,5 @@
|
|||
module code.bcarlin.net/go/logging
|
||||
module code.bcarlin.xyz/go/logging
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/stretchr/testify v1.7.1
|
||||
require github.com/stretchr/testify v1.7.1 // indirect
|
||||
|
|
1
go.sum
1
go.sum
|
@ -5,7 +5,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
@ -103,7 +103,7 @@ func GetLogger(name string) *Logger {
|
|||
|
||||
func defaultFormatter(r *Record) string {
|
||||
return fmt.Sprintf("%s [%-8s] %s: %s\n",
|
||||
r.Timestamp.Format("2006/01/02 15:04:05.999999"), r.Level.Name(), r.Logger,
|
||||
r.Timestamp.Format("2006/01/02 15:04:05"), r.Level.Name(), r.Logger,
|
||||
strings.TrimSpace(r.Message))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func Test_LevelByName(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
@ -22,19 +16,3 @@ func Test_LevelByName(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_defaultFormatter(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
r := &Record{
|
||||
Timestamp: time.Date(2000, 0o1, 0o2, 0o3, 0o4, 0o5, 123456789, time.Local),
|
||||
Level: Info,
|
||||
Logger: "my logger",
|
||||
Message: "my log line",
|
||||
}
|
||||
|
||||
got := defaultFormatter(r)
|
||||
want := fmt.Sprintf("2000/01/02 03:04:05.123456 [INFO ] my logger: my log line\n")
|
||||
|
||||
assert.Equal(t, want, got)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue