mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
update golog dependency
This commit is contained in:
parent
db393f2e2a
commit
0ef064cc55
|
@ -10,7 +10,9 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
app := iris.New()
|
app := iris.New()
|
||||||
app.Logger().SetLevel("debug")
|
app.Logger().SetLevel("debug")
|
||||||
app.Logger().Handle(golog.JSON(" ")) /* see below to manually create a handler */
|
app.Logger().SetFormat("json", " ")
|
||||||
|
// to register a custom Formatter:
|
||||||
|
// app.Logger().RegisterFormatter(golog.Formatter...)
|
||||||
|
|
||||||
// Also, see app.Logger().SetLevelOutput(level string, w io.Writer)
|
// Also, see app.Logger().SetLevelOutput(level string, w io.Writer)
|
||||||
// to set a custom writer for a specific level.
|
// to set a custom writer for a specific level.
|
||||||
|
@ -79,15 +81,3 @@ func ping(ctx iris.Context) {
|
||||||
|
|
||||||
ctx.WriteString("pong")
|
ctx.WriteString("pong")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manually. Use it for any custom format:
|
|
||||||
func jsonOutput(l *golog.Log) bool {
|
|
||||||
// you can change the output to a file as well.
|
|
||||||
enc := json.NewEncoder(l.Logger.GetLevelOutput(l.Level.String()))
|
|
||||||
enc.SetIndent("", " ")
|
|
||||||
err := enc.Encode(l)
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Logger().Handle(jsonOutput)
|
|
||||||
*/
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestJSONLogger(t *testing.T) {
|
||||||
|
|
||||||
app.Get("/ping", ping)
|
app.Get("/ping", ping)
|
||||||
|
|
||||||
const expectedLogStr = `{"level":"debug","message":"Request path: /ping","fields":{"request_id":null},"stacktrace":[{"function":"json-logger/ping","source":"C:/mygopath/src/github.com/kataras/iris/_examples/logging/json-logger/main.go:76"}]}`
|
const expectedLogStr = `{"level":"debug","message":"Request path: /ping","fields":{"request_id":null},"stacktrace":[{"function":"json-logger/ping","source":"C:/mygopath/src/github.com/kataras/iris/_examples/logging/json-logger/main.go:78"}]}`
|
||||||
e := httptest.New(t, app, httptest.LogLevel("debug"))
|
e := httptest.New(t, app, httptest.LogLevel("debug"))
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
wg.Add(iters)
|
wg.Add(iters)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -20,7 +20,7 @@ require (
|
||||||
github.com/iris-contrib/schema v0.0.6
|
github.com/iris-contrib/schema v0.0.6
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10
|
||||||
github.com/kataras/blocks v0.0.3
|
github.com/kataras/blocks v0.0.3
|
||||||
github.com/kataras/golog v0.1.4
|
github.com/kataras/golog v0.1.5
|
||||||
github.com/kataras/neffos v0.0.16
|
github.com/kataras/neffos v0.0.16
|
||||||
github.com/kataras/pio v0.0.10
|
github.com/kataras/pio v0.0.10
|
||||||
github.com/kataras/sitemap v0.0.5
|
github.com/kataras/sitemap v0.0.5
|
||||||
|
|
Loading…
Reference in New Issue
Block a user