Skip to content

Commit

Permalink
chore: refactoring (#2182)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Jul 22, 2022
1 parent 34eb3fc commit 92145b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions core/logx/rotatelogger.go
Expand Up @@ -19,14 +19,14 @@ import (
)

const (
rfc3339DateFormat = time.RFC3339
dateFormat = "2006-01-02"
hoursPerDay = 24
bufferSize = 100
defaultDirMode = 0o755
defaultFileMode = 0o600
gzipExt = ".gz"
megaBytes = 1 << 20
dateFormat = "2006-01-02"
fileTimeFormat = time.RFC3339
hoursPerDay = 24
bufferSize = 100
defaultDirMode = 0o755
defaultFileMode = 0o600
gzipExt = ".gz"
megaBytes = 1 << 20
)

// ErrLogFileClosed is an error that indicates the log file is already closed.
Expand Down Expand Up @@ -195,7 +195,7 @@ func (r *SizeLimitRotateRule) OutdatedFiles() []string {

// test if any too old backups
if r.days > 0 {
boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(rfc3339DateFormat)
boundary := time.Now().Add(-time.Hour * time.Duration(hoursPerDay*r.days)).Format(fileTimeFormat)
boundaryFile := filepath.Join(dir, fmt.Sprintf("%s%s%s%s", prefix, r.delimiter, boundary, ext))
if r.gzip {
boundaryFile += gzipExt
Expand Down Expand Up @@ -413,7 +413,7 @@ func getNowDate() string {
}

func getNowDateInRFC3339Format() string {
return time.Now().Format(rfc3339DateFormat)
return time.Now().Format(fileTimeFormat)
}

func gzipFile(file string) error {
Expand Down
2 changes: 1 addition & 1 deletion core/logx/rotatelogger_test.go
Expand Up @@ -51,7 +51,7 @@ func TestSizeLimitRotateRuleOutdatedFiles(t *testing.T) {

func TestSizeLimitRotateRuleShallRotate(t *testing.T) {
var rule SizeLimitRotateRule
rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(rfc3339DateFormat)
rule.rotatedTime = time.Now().Add(time.Hour * 24).Format(fileTimeFormat)
rule.maxSize = 0
assert.False(t, rule.ShallRotate(0))
rule.maxSize = 100
Expand Down
6 changes: 3 additions & 3 deletions zrpc/internal/rpcpubserver.go
Expand Up @@ -41,12 +41,12 @@ type keepAliveServer struct {
Server
}

func (ags keepAliveServer) Start(fn RegisterFn) error {
if err := ags.registerEtcd(); err != nil {
func (s keepAliveServer) Start(fn RegisterFn) error {
if err := s.registerEtcd(); err != nil {
return err
}

return ags.Server.Start(fn)
return s.Server.Start(fn)
}

func figureOutListenOn(listenOn string) string {
Expand Down

0 comments on commit 92145b5

Please sign in to comment.