1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00

accesslog: new HumanTime option as requested at #1661

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-10-16 09:53:22 +03:00
parent 8e51a296b9
commit b816156e77
2 changed files with 52 additions and 4 deletions

View File

@@ -25,7 +25,13 @@ func (f *JSON) writeEasyJSON(in *Log) error {
} else {
out.RawString(prefix)
}
out.Int64(int64(in.Timestamp))
if f.HumanTime {
t := in.Now.Format(in.TimeFormat)
out.String(t)
} else {
out.Int64(in.Timestamp)
}
}
{
const prefix string = ",\"latency\":"
@@ -40,17 +46,17 @@ func (f *JSON) writeEasyJSON(in *Log) error {
{
const prefix string = ",\"method\":"
out.RawString(prefix)
out.String(string(in.Method))
out.String(in.Method)
}
{
const prefix string = ",\"path\":"
out.RawString(prefix)
out.String(string(in.Path))
out.String(in.Path)
}
if in.IP != "" {
const prefix string = ",\"ip\":"
out.RawString(prefix)
out.String(string(in.IP))
out.String(in.IP)
}
if len(in.Query) != 0 {
const prefix string = ",\"query\":"