authelia/logging/logger.go
Clement Michaud 828f565290 Bootstrap Go implementation of Authelia.
This is going to be the v4.

Expected improvements:
- More reliable due to static typing.
- Bump of performance.
- Improvement of logging.
- Authelia can be shipped as a single binary.
- Will likely work on ARM architecture.
2019-10-28 23:28:59 +01:00

26 lines
600 B
Go

package logging
import (
"github.com/sirupsen/logrus"
"github.com/valyala/fasthttp"
)
// Logger return the standard logrues logger.
func Logger() *logrus.Logger {
return logrus.StandardLogger()
}
// NewRequestLogger create a new request logger for the given request.
func NewRequestLogger(ctx *fasthttp.RequestCtx) *logrus.Entry {
return logrus.WithFields(logrus.Fields{
"method": string(ctx.Method()),
"path": string(ctx.Path()),
"remote_ip": ctx.RemoteIP().String(),
})
}
// SetLevel set the level of the logger.
func SetLevel(level logrus.Level) {
logrus.SetLevel(level)
}