Integrating with existing zerologger undefined
rrajkowski opened this issue · 2 comments
rrajkowski commented
Hi im using echo v4 and go1.19.3 and docs say to use v2 of lecho:
My code below
package main
import (
"os"
"github.com/labstack/echo/v4"
"github.com/rs/zerolog"
"github.com/ziflex/lecho/v3"
)
func main() {
log := zerolog.New(os.Stdout)
e := echo.New()
e.Logger = lecho.From(log)
//write log from context
e.GET("/", func(c echo.Context) error {
c.Logger().Print("Echo interface")
})
}
// Output
lecho.New undefined (type *lecho.Logger has no field or method New)
lecho.New undefined (type *lecho.Logger has no field or method From)
Q: is there another version or am im missing something to integrate with zerolog?
I've tried:
import (
"github.com/ziflex/lecho/v3"
"github.com/ziflex/lecho"
)
Thanks in advance
rrajkowski commented
after testing with v3 i got it working by reordering definitions, Thanks!
func main() {
e := echo.New()
log := zerolog.New(os.Stdout)
e.Logger = lecho.From(log)
//write log from context
e.GET("/", func(c echo.Context) error {
c.Logger().Print("Echo interface")
return nil
})
}
rrajkowski commented
closed