mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
new accesslog middleware: require the writer inside its constructor so we can 'detect' if we must force-lock a writer
relative to: https://github.com/kataras/iris/issues/1601
This commit is contained in:
@@ -18,8 +18,8 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ac := accesslog.New()
|
||||
ac.SetOutput(w)
|
||||
ac := accesslog.New(w)
|
||||
ac.TimeFormat = "2006-01-02 15:04:05"
|
||||
|
||||
/*
|
||||
Use a file directly:
|
||||
@@ -28,12 +28,9 @@ 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 = ""
|
||||
Force-protect writer with locks.
|
||||
On this example this is not required:
|
||||
ac.LockWriter = true"
|
||||
|
||||
Add second output:
|
||||
ac.AddOutput(app.Logger().Printer)
|
||||
|
||||
Reference in New Issue
Block a user