2023-02-27 12:20:07 +01:00
|
|
|
package formatter
|
|
|
|
|
2024-07-03 11:33:02 +02:00
|
|
|
import (
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
2023-02-27 12:20:07 +01:00
|
|
|
|
2023-03-17 10:37:27 +01:00
|
|
|
// SetTextFormatter set the text formatter for given logger.
|
2023-02-27 12:20:07 +01:00
|
|
|
func SetTextFormatter(logger *logrus.Logger) {
|
|
|
|
logger.Formatter = NewTextFormatter()
|
|
|
|
logger.ReportCaller = true
|
|
|
|
logger.AddHook(NewContextHook())
|
|
|
|
}
|
2024-08-01 18:22:02 +02:00
|
|
|
// SetSyslogFormatter set the text formatter for given logger.
|
|
|
|
func SetSyslogFormatter(logger *logrus.Logger) {
|
|
|
|
logger.Formatter = NewSyslogFormatter()
|
|
|
|
logger.ReportCaller = true
|
|
|
|
logger.AddHook(NewContextHook())
|
|
|
|
}
|
2023-03-17 10:37:27 +01:00
|
|
|
|
2024-07-03 11:33:02 +02:00
|
|
|
// SetJSONFormatter set the JSON formatter for given logger.
|
|
|
|
func SetJSONFormatter(logger *logrus.Logger) {
|
|
|
|
logger.Formatter = &logrus.JSONFormatter{}
|
|
|
|
logger.ReportCaller = true
|
|
|
|
logger.AddHook(NewContextHook())
|
|
|
|
}
|
|
|
|
|
2023-03-17 10:37:27 +01:00
|
|
|
// SetLogcatFormatter set the logcat formatter for given logger.
|
|
|
|
func SetLogcatFormatter(logger *logrus.Logger) {
|
|
|
|
logger.Formatter = NewLogcatFormatter()
|
|
|
|
logger.ReportCaller = true
|
|
|
|
logger.AddHook(NewContextHook())
|
|
|
|
}
|