1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-26 14:46:24 -07:00

Use more context/timeout queries in gochan-migrate, start using zerolog

This commit is contained in:
Eggbertx 2024-10-13 13:43:08 -07:00
parent 9d003d89a3
commit eb06047055
11 changed files with 307 additions and 200 deletions

View file

@ -65,10 +65,10 @@ func LogDiscard(events ...*zerolog.Event) {
}
}
// isTerminal returns true if the ModeCharDevice bit is set, meaning that
// RunningInTerminal returns true if the ModeCharDevice bit is set, meaning that
// gochan is probably running in a standard terminal and not being piped
// to a file
func isTerminal() bool {
func RunningInTerminal() bool {
fi, err := os.Stdout.Stat()
if err != nil {
return false
@ -91,7 +91,7 @@ func initLog(logPath string, logToConsole bool) (err error) {
var writer io.Writer
if logToConsole {
cw := zerolog.NewConsoleWriter()
cw.NoColor = !isTerminal()
cw.NoColor = !RunningInTerminal()
writer = zerolog.MultiLevelWriter(logFile, cw)
} else {
writer = logFile