Skip to content

Commit

Permalink
add format time (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
huweihuang authored Dec 12, 2023
1 parent d9cd173 commit 71984dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion logger/example/zap/zap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMainZap(t *testing.T) {
}

func TestLogger(t *testing.T) {
log.InitLogger("", "", "debug", "text", true)
log.InitLogger("log/info.log", "error.log", "debug", "text", true)

log.Logger().Infof("test default log")
log.Logger().Infow("failed to fetch URL",
Expand Down
6 changes: 6 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/rand"
"os"
"path/filepath"
"time"
)

const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789"
Expand Down Expand Up @@ -45,3 +46,8 @@ func MakeParentDir(fullFilePath string) error {
}
return nil
}

func FormatTime(t time.Time) string {
local, _ := time.LoadLocation("Asia/Shanghai")
return t.In(local).Format("2006-01-02 15:04:05")
}

0 comments on commit 71984dc

Please sign in to comment.