Skip to content

Commit 3b5c56d

Browse files
authored
Merge pull request #11 from randlabs/redesign
Improved syslog code and updates
2 parents c4ff054 + 5f4af58 commit 3b5c56d

File tree

6 files changed

+241
-77
lines changed

6 files changed

+241
-77
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ go 1.13
44

55
require (
66
github.com/gookit/color v1.5.0
7-
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f // indirect
7+
github.com/randlabs/rundown-protection v1.0.4
8+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
89
)

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw=
44
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
55
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/randlabs/rundown-protection v1.0.4 h1:rQuJf1+cKFsxqfFgcQuz7y+spqqKtDR4i2xeJZQ2gdQ=
8+
github.com/randlabs/rundown-protection v1.0.4/go.mod h1:rccYmsidTaGDOvZSAF9eYsLzMVvh9tj043JyTicfQ5o=
79
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
810
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
911
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1012
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
1113
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
1214
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13-
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f h1:8w7RhxzTVgUzw/AH/9mUV5q0vMgy40SQRursCcfmkCw=
14-
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
16+
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1517
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1618
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1719
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

internal/file/file.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ var newLine = "\n"
1919

2020
//------------------------------------------------------------------------------
2121

22-
// Options specifies the file logger settings to use when it is created.
23-
type Options struct {
24-
Prefix string `json:"prefix,omitempty"`
25-
Directory string `json:"dir,omitempty"`
26-
DaysToKeep uint `json:"daysToKeep,omitempty"`
27-
ErrorHandler ErrorHandler
28-
}
29-
3022
// Logger is the object that controls file logging.
3123
type Logger struct {
3224
mtx sync.Mutex
@@ -39,6 +31,21 @@ type Logger struct {
3931
errorHandler ErrorHandler
4032
}
4133

34+
// Options specifies the file logger settings to use when it is created.
35+
type Options struct {
36+
// Filename prefix to use when a file is created. Defaults to the binary name.
37+
Prefix string `json:"prefix,omitempty"`
38+
39+
// Destination directory to store log files.
40+
Directory string `json:"dir,omitempty"`
41+
42+
// Amount of days to keep old logs.
43+
DaysToKeep uint `json:"daysToKeep,omitempty"`
44+
45+
// A callback to call if an internal error is encountered.
46+
ErrorHandler ErrorHandler
47+
}
48+
4249
// ErrorHandler is a callback to call if an internal error must be notified.
4350
type ErrorHandler func(message string)
4451

0 commit comments

Comments
 (0)