Files
archived-rttys-zhaojh329/log/log.go
T
Jianhui Zhao 2489b605a7 Remove log file fallback for non-TTY output
The feature that wrote logs to a file when stdout wasn't a terminal is
removed. Systemd services already handle log persistence through journald
and its logging facilities. This duplication is unnecessary and conflicts
with standard systemd logging practices.

View log in systemd:

```
journalctl -u rttys
```

or

```
journalctl -u rttys -f
```

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
2025-07-29 14:55:29 +08:00

29 lines
589 B
Go

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()
}