Skip to content

Commit

Permalink
format time to Javascript ISO8601 format
Browse files Browse the repository at this point in the history
  • Loading branch information
isayme committed Apr 20, 2018
1 parent fc46806 commit ea91285
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ func developmentConsume(log Log, ctx *gear.Context) {
}

// New creates a Logger instance with given io.Writer and DebugLevel log level.
// the logger timestamp format is "2006-01-02T15:04:05.999Z"(JavaScript ISO date string), log format is "[%s] %s %s"
// the logger timestamp format is "2006-01-02T15:04:05.000Z"(JavaScript ISO date string), log format is "[%s] %s %s"
func New(w io.Writer) *Logger {
logger := &Logger{Out: w}
logger.SetLevel(DebugLevel)
logger.SetTimeFormat("2006-01-02T15:04:05.999Z")
logger.SetTimeFormat("2006-01-02T15:04:05.000Z")
logger.SetLogFormat("[%s] %s %s")

logger.init = func(log Log, ctx *gear.Context) {
Expand Down Expand Up @@ -403,7 +403,7 @@ func (l *Logger) SetLevel(level Level) *Logger {
}

// SetTimeFormat set the logger timestamp format
// The default logger timestamp format is "2006-01-02T15:04:05.999Z"(JavaScript ISO date string)
// The default logger timestamp format is "2006-01-02T15:04:05.000Z"(JavaScript ISO date string)
func (l *Logger) SetTimeFormat(timeFormat string) *Logger {
l.mu.Lock()
defer l.mu.Unlock()
Expand Down

0 comments on commit ea91285

Please sign in to comment.