Skip to content
/ eglm Public

gwlog in the log middleware of the echo framework.

License

Notifications You must be signed in to change notification settings

GameWith/eglm

Repository files navigation

eglm

echo log middleware library dedicated to gwlog.

Usage

Please add it to Middleware of echo.

Also, set gwlog.Logger for the Logger of the echo.

e := echo.New()
logger := gwlog.GetLogger()
logger.SetOutput(os.Stdout)
e.Logger = logger
e.Use(eglm.Middleware(&Config{}))

Options

Skipper

Log output is skip if the conditions are met in request.

The default is not to skip everything.

e := echo.New()
e.Logger = gwlog.GetLogger()
e.Use(eglm.Logger(&Config{
    Skipper: func(c echo.Context) bool {
        return c.Path() == "/"
    },
}))

LoggingFunc

Write the log via Middleware.

Use this when you want to customize the log contents.

If nothing is set, eglm.DefaultLoggingFunc will be set.

e := echo.New()
e.Logger = gwlog.GetLogger()
e.Use(eglm.Logger(&Config{
    LoggingFunc: func(logger gwlog.Logger, p *Parameter, c echo.Context) error {
    	logger.Print("a")
        return nil
    },
}))

About

gwlog in the log middleware of the echo framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published