mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
34 lines
678 B
Go
34 lines
678 B
Go
/* SPDX-License-Identifier: MIT */
|
|
/*
|
|
* Author: Jianhui Zhao <zhaojh329@gmail.com>
|
|
*/
|
|
|
|
package log
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strconv"
|
|
|
|
"github.com/dwdcth/consoleEx"
|
|
"github.com/mattn/go-colorable"
|
|
"github.com/rs/zerolog"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func init() {
|
|
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
|
|
return filepath.Base(file) + ":" + strconv.Itoa(line)
|
|
}
|
|
|
|
out := consoleEx.ConsoleWriterEx{Out: colorable.NewColorableStdout()}
|
|
logger := zerolog.New(out).With().Timestamp().Logger()
|
|
|
|
log.Logger = logger
|
|
|
|
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
|
}
|
|
|
|
func Verbose() {
|
|
log.Logger = log.Logger.With().Caller().Logger()
|
|
}
|