~adnano/astronaut

ref: 72ba913688a9d2dafb0bfdf11a5cee16685ce98a astronaut/log.go -rw-r--r-- 290 bytes
72ba9136Adnan Maolood Use scfg to configure settings 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package main

import (
	"io"
	"log"
	"os"
)

func init() {
	// Disable logging if os.Stderr is a TTY
	stat, err := os.Stderr.Stat()
	if err != nil {
		panic(err)
	}
	if tty := (stat.Mode() & os.ModeCharDevice) != 0; tty {
		// Discard log entries
		log.Default().SetOutput(io.Discard)
	}
}