mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
accesslog: Timestamp to unix milliseconds instead of seconds
relative to https://github.com/kataras/iris/issues/1601#issuecomment-690868305
This commit is contained in:
@@ -553,7 +553,7 @@ func (ac *AccessLog) Print(ctx *context.Context, latency time.Duration, timeForm
|
||||
log.Logger = ac
|
||||
log.Now = now
|
||||
log.TimeFormat = timeFormat
|
||||
log.Timestamp = now.Unix()
|
||||
log.Timestamp = now.UnixNano() / 1000000
|
||||
log.Latency = latency
|
||||
log.Method = method
|
||||
log.Path = path
|
||||
|
||||
@@ -23,7 +23,7 @@ type Log struct {
|
||||
// TimeFormat selected to print the Time as string,
|
||||
// useful on Template Formatter.
|
||||
TimeFormat string `json:"-" yaml:"-" toml:"-"`
|
||||
// Timestamp the Now's unix timestamp (seconds).
|
||||
// Timestamp the Now's unix timestamp (milliseconds).
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
|
||||
// Request-Response latency.
|
||||
@@ -192,10 +192,12 @@ type Template struct {
|
||||
// Custom template source.
|
||||
// Use this or `Tmpl/TmplName` fields.
|
||||
Text string
|
||||
// Custom template to use, overrides the `Text` field if not nil.
|
||||
// Custom template funcs to used when `Text` is not empty.
|
||||
Funcs template.FuncMap
|
||||
|
||||
// Custom template to use, overrides the `Text` and `Funcs` fields.
|
||||
Tmpl *template.Template
|
||||
// If not empty then this named template/block
|
||||
// is response to hold the log result.
|
||||
// If not empty then this named template/block renders the log line.
|
||||
TmplName string
|
||||
|
||||
dest io.Writer
|
||||
@@ -206,12 +208,16 @@ type Template struct {
|
||||
// when this formatter is registered.
|
||||
func (f *Template) SetOutput(dest io.Writer) {
|
||||
if f.Tmpl == nil {
|
||||
tmpl := template.New("")
|
||||
|
||||
text := f.Text
|
||||
if f.Text == "" {
|
||||
if text != "" {
|
||||
tmpl.Funcs(f.Funcs)
|
||||
} else {
|
||||
text = defaultTmplText
|
||||
}
|
||||
|
||||
f.Tmpl = template.Must(template.New("").Parse(text))
|
||||
f.Tmpl = template.Must(tmpl.Parse(text))
|
||||
}
|
||||
|
||||
f.dest = dest
|
||||
|
||||
Reference in New Issue
Block a user