mirror of
https://github.com/hanzoai/beego.git
synced 2026-11-17 13:19:25 +00:00
Patches against upstream beego/[email protected]: server/web/admin_controller.go — promhttp.Handler → luxfi/metric HTTP handler server/web/filter/prometheus/ — luxfi/metric backend, drops MustRegister client/httplib/filter/prometheus/ — luxfi/metric backend client/orm/filter/prometheus/ — luxfi/metric backend core/config/etcd/config.go — drop grpc-ecosystem/go-grpc-prometheus interceptors (etcd dialing has no observability through this path) Default closure: 0 grpc, 0 protobuf, 0 prometheus/client_golang. Consumers in hanzoai/iam see the fork through workspace mode.
1.2 KiB
1.2 KiB
logs
logs is a Go logs manager. It can use many logs adapters. The repo is inspired by database/sql .
How to install?
go get github.com/beego/beego/v2/core/logs
What adapters are supported?
As of now this logs support console, file,smtp and conn.
How to use it?
First you must import it
import (
"github.com/beego/beego/v2/core/logs"
)
Then init a Log (example with console adapter)
log := logs.NewLogger(10000)
log.SetLogger("console", "")
the first params stand for how many channel
Use it like this:
log.Trace("trace")
log.Info("info")
log.Warn("warning")
log.Debug("debug")
log.Critical("critical")
File adapter
Configure file adapter like this:
log := NewLogger(10000)
log.SetLogger("file", `{"filename":"test.log"}`)
Conn adapter
Configure like this:
log := NewLogger(1000)
log.SetLogger("conn", `{"net":"tcp","addr":":7020"}`)
log.Info("info")
Smtp adapter
Configure like this:
log := NewLogger(10000)
log.SetLogger("smtp", `{"username":"[email protected]","password":"xxxxxxxx","host":"smtp.gmail.com:587","sendTos":["[email protected]"]}`)
log.Critical("sendmail critical")
time.Sleep(time.Second * 30)