1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

accesslog: LockWriter (to lock unprotected writers) and Clock (for testing)

relative to: https://github.com/kataras/iris/issues/1601
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-07 16:31:43 +03:00
parent 4c6568b874
commit e96a009d3f
3 changed files with 173 additions and 27 deletions

View File

@@ -20,6 +20,7 @@ func main() {
}
ac := accesslog.New()
ac.SetOutput(w)
/*
Use a file directly:
ac := accesslog.File("./access.log")
@@ -27,11 +28,15 @@ func main() {
Log after the response was sent:
ac.Async = true
Protect writer with locks.
On this example this is not required but enable it on os.Stdout and e.t.c:
ac.LockWriter = true
Custom Time Format:
ac.TimeFormat = ""
Add second output:
ac.AddOutput(os.Stdout)
ac.AddOutput(app.Logger().Printer)
Change format (after output was set):
ac.SetFormatter(&accesslog.JSON{Indent: " "})