|
|
|
|
@ -5,12 +5,12 @@ import (
|
|
|
|
|
"io"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
|
|
"github.com/natefinch/lumberjack"
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
"github.com/synctv-org/synctv/cmd/flags"
|
|
|
|
|
"github.com/synctv-org/synctv/internal/conf"
|
|
|
|
|
"github.com/synctv-org/synctv/utils"
|
|
|
|
|
"github.com/zijiren233/go-colorable"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -27,9 +27,7 @@ func setLog(l *logrus.Logger) {
|
|
|
|
|
func InitLog(ctx context.Context) error {
|
|
|
|
|
setLog(logrus.StandardLogger())
|
|
|
|
|
if conf.Conf.Log.Enable {
|
|
|
|
|
if !filepath.IsAbs(conf.Conf.Log.FilePath) {
|
|
|
|
|
conf.Conf.Log.FilePath = filepath.Join(flags.DataDir, conf.Conf.Log.FilePath)
|
|
|
|
|
}
|
|
|
|
|
utils.OptFilePath(&conf.Conf.Log.FilePath)
|
|
|
|
|
var l = &lumberjack.Logger{
|
|
|
|
|
Filename: conf.Conf.Log.FilePath,
|
|
|
|
|
MaxSize: conf.Conf.Log.MaxSize,
|
|
|
|
|
|