/* * SPDX-License-Identifier: AGPL-3.0-only * Copyright (c) 2022-2023, v2rayA Organization */ 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 }