https://github.com/spirosoik/echo-logrus
A logging middleware for minimal golang Echo framework with logrus
https://github.com/spirosoik/echo-logrus
echo-framework golang logging middleware
Last synced: 3 months ago
JSON representation
A logging middleware for minimal golang Echo framework with logrus
- Host: GitHub
- URL: https://github.com/spirosoik/echo-logrus
- Owner: spirosoik
- License: apache-2.0
- Created: 2020-06-20T07:26:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T08:59:19.000Z (over 5 years ago)
- Last Synced: 2025-03-28T02:23:40.540Z (10 months ago)
- Topics: echo-framework, golang, logging, middleware
- Language: Go
- Size: 9.77 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# echo-logger
A logging middleware for minimal golang Echo framework with logrus
## Usage
```go
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
echologrus "github.com/spirosoik/echo-logrus"
)
func main() {
e := echo.New()
logger := logrus.New()
logger.SetLevel(logrus.DebugLevel)
// Usage of middleware
mw := echologrus.NewLoggerMiddleware(logger)
e.Logger = mw
e.Use(mw.Hook())
e.GET("/", func(c echo.Context) error {
c.Logger().Debug("test") // test logging
c.Logger().Warn("test") // test logging
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":3000"))
}
```
There is an example in [_example](_examples/) folder and you can run it:
```bash
# in one terminal
go run _examples/main.go
```
```bash
# in second terminal
curl localhost:3000
```
# Contributors
[Roel Reijerse](https://github.com/rollulus) Software Engineer