mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-05 13:08:57 +07:00
30 lines
601 B
Go
30 lines
601 B
Go
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* Copyright (c) 2022-2023, v2rayA Organization <team@v2raya.org>
|
|
*/
|
|
|
|
package logger
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
|
)
|
|
|
|
func NewLogger(logLevel string, disableTimestamp bool) *logrus.Logger {
|
|
log := logrus.New()
|
|
|
|
level, err := logrus.ParseLevel(logLevel)
|
|
if err != nil {
|
|
level = logrus.InfoLevel
|
|
}
|
|
|
|
log.SetLevel(level)
|
|
log.SetFormatter(&prefixed.TextFormatter{
|
|
DisableTimestamp: disableTimestamp,
|
|
FullTimestamp: true,
|
|
TimestampFormat: "Jan 02 15:04:05",
|
|
})
|
|
|
|
return log
|
|
}
|