Skip to content

Commit

Permalink
Use /dev/null as a log writer by default (#15)
Browse files Browse the repository at this point in the history
* Use /dev/null as a log writer by default

* Update
  • Loading branch information
nakabonne authored Nov 11, 2020
1 parent 3ab239a commit 676660f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ brew install nakabonne/gosivy/gosivy
#### RHEL/CentOS

```
rpm -ivh https://github.com/nakabonne/gosivy/releases/download/v0.1.1/gosivy_0.1.1_linux_amd64.rpm
rpm -ivh https://github.com/nakabonne/gosivy/releases/download/v0.2.0/gosivy_0.2.0_linux_amd64.rpm
```

#### Debian/Ubuntu

```
wget https://github.com/nakabonne/gosivy/releases/download/v0.1.1/gosivy_0.1.1_linux_amd64.deb
apt install ./gosivy_0.1.1_linux_amd64.deb
wget https://github.com/nakabonne/gosivy/releases/download/v0.2.0/gosivy_0.2.0_linux_amd64.deb
apt install ./gosivy_0.2.0_linux_amd64.deb
```

#### Go
Expand Down
5 changes: 2 additions & 3 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Options struct {
// By default "127.0.0.1:0" is populated.
Addr string

// Where to emit the log to. By default os.Stderr is used.
// Where to emit the log to. By default ioutil.Discard is used.
LogWriter io.Writer
}

Expand All @@ -55,7 +55,7 @@ func Listen(opts Options) error {
defer mu.Unlock()
logWriter = opts.LogWriter
if logWriter == nil {
logWriter = os.Stderr
logWriter = ioutil.Discard
}

if pidFile != "" {
Expand Down Expand Up @@ -149,7 +149,6 @@ func listen() {
// handle keeps using the given connection until an issue occurred.
func handle(conn net.Conn) error {
defer conn.Close()

for {
conn.SetReadDeadline(time.Now().Add(5 * time.Second))
sig := make([]byte, 1)
Expand Down
2 changes: 1 addition & 1 deletion diagnoser/diagnoser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package diagnoser mainly provides two components, scraper and TUI
// Package diagnoser mainly provides two components, scraper and GUI
// for the process diagnosis.
package diagnoser

Expand Down
6 changes: 5 additions & 1 deletion examples/local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package main
import (
"fmt"
"log"
"os"
"time"

"github.com/nakabonne/gosivy/agent"
)

func main() {
if err := agent.Listen(agent.Options{}); err != nil {
err := agent.Listen(agent.Options{
LogWriter: os.Stdout,
})
if err != nil {
log.Fatal(err)
}
defer agent.Close()
Expand Down

0 comments on commit 676660f

Please sign in to comment.