Skip to content

Commit 676660f

Browse files
authored
Use /dev/null as a log writer by default (#15)
* Use /dev/null as a log writer by default * Update
1 parent 3ab239a commit 676660f

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ brew install nakabonne/gosivy/gosivy
2020
#### RHEL/CentOS
2121

2222
```
23-
rpm -ivh https://github.com/nakabonne/gosivy/releases/download/v0.1.1/gosivy_0.1.1_linux_amd64.rpm
23+
rpm -ivh https://github.com/nakabonne/gosivy/releases/download/v0.2.0/gosivy_0.2.0_linux_amd64.rpm
2424
```
2525

2626
#### Debian/Ubuntu
2727

2828
```
29-
wget https://github.com/nakabonne/gosivy/releases/download/v0.1.1/gosivy_0.1.1_linux_amd64.deb
30-
apt install ./gosivy_0.1.1_linux_amd64.deb
29+
wget https://github.com/nakabonne/gosivy/releases/download/v0.2.0/gosivy_0.2.0_linux_amd64.deb
30+
apt install ./gosivy_0.2.0_linux_amd64.deb
3131
```
3232

3333
#### Go

agent/agent.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type Options struct {
4040
// By default "127.0.0.1:0" is populated.
4141
Addr string
4242

43-
// Where to emit the log to. By default os.Stderr is used.
43+
// Where to emit the log to. By default ioutil.Discard is used.
4444
LogWriter io.Writer
4545
}
4646

@@ -55,7 +55,7 @@ func Listen(opts Options) error {
5555
defer mu.Unlock()
5656
logWriter = opts.LogWriter
5757
if logWriter == nil {
58-
logWriter = os.Stderr
58+
logWriter = ioutil.Discard
5959
}
6060

6161
if pidFile != "" {
@@ -149,7 +149,6 @@ func listen() {
149149
// handle keeps using the given connection until an issue occurred.
150150
func handle(conn net.Conn) error {
151151
defer conn.Close()
152-
153152
for {
154153
conn.SetReadDeadline(time.Now().Add(5 * time.Second))
155154
sig := make([]byte, 1)

diagnoser/diagnoser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package diagnoser mainly provides two components, scraper and TUI
1+
// Package diagnoser mainly provides two components, scraper and GUI
22
// for the process diagnosis.
33
package diagnoser
44

examples/local/main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ package main
33
import (
44
"fmt"
55
"log"
6+
"os"
67
"time"
78

89
"github.com/nakabonne/gosivy/agent"
910
)
1011

1112
func main() {
12-
if err := agent.Listen(agent.Options{}); err != nil {
13+
err := agent.Listen(agent.Options{
14+
LogWriter: os.Stdout,
15+
})
16+
if err != nil {
1317
log.Fatal(err)
1418
}
1519
defer agent.Close()

0 commit comments

Comments
 (0)