refactored logging initialization

This commit is contained in:
2025-09-14 16:57:52 -06:00
parent 21c943d992
commit e76426feff
2 changed files with 10 additions and 7 deletions
+8
View File
@@ -17,6 +17,14 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func init() {
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
log.SetLevel(log.InfoLevel)
}
func toglog(l log.Level) glog.Lvl { func toglog(l log.Level) glog.Lvl {
switch l { switch l {
case log.DebugLevel: case log.DebugLevel:
+2 -7
View File
@@ -12,7 +12,6 @@ import (
"git.erbosoft.com/amy/amsterdam/ui" "git.erbosoft.com/amy/amsterdam/ui"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
log "github.com/sirupsen/logrus"
) )
func setupEcho() *echo.Echo { func setupEcho() *echo.Echo {
@@ -21,21 +20,17 @@ func setupEcho() *echo.Echo {
e.Renderer = &ui.TemplateRenderer{} e.Renderer = &ui.TemplateRenderer{}
e.Use(middleware.Recover()) e.Use(middleware.Recover())
e.Use(LogrusMiddleware) e.Use(LogrusMiddleware)
e.GET("/img/*", ui.AmWrap(ui.AmServeImage)) e.GET("/img/*", ui.AmWrap(ui.AmServeImage))
e.GET("/", ui.AmWrap(func(ctxt ui.AmContext) (string, any, error) { e.GET("/", ui.AmWrap(func(ctxt ui.AmContext) (string, any, error) {
ctxt.VarMap().Set("amsterdam_pageTitle", "My Front Page") ctxt.VarMap().Set("amsterdam_pageTitle", "My Front Page")
return "framed_template", "top.jet", nil return "framed_template", "top.jet", nil
})) }))
return e return e
} }
func main() { func main() {
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
TimestampFormat: "2006-01-02 15:04:05",
})
log.SetLevel(log.InfoLevel)
e := setupEcho() e := setupEcho()
e.Logger.Fatal(e.Start(":1323")) e.Logger.Fatal(e.Start(":1323"))