Skip to content

Commit

Permalink
Harmonize the log options between the forwarder and the server
Browse files Browse the repository at this point in the history
Closes #11.
  • Loading branch information
elwinar committed Mar 17, 2020
1 parent 7d1eed8 commit dde02f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ Usage of rcoredumpd: rcoredumpd [options]
configuration file to load (default "/etc/rcoredump/rcoredumpd.conf")
-dir string
path of the directory to store data into (default "/var/lib/rcoredumpd")
-filelog string
path of the file to log into ("-" for stdout) (default "-")
-go.analyzer string
command to run to analyze Go core dumps (default "dlv core {{ .Executable }} {{ .Core }} --init {{ .Dir }}/delve.cmd")
-index-type string
type of index to use (values: bleve) (default "bleve")
-syslog
output logs to syslog
-version
print the version of rcoredumpd
```
Expand All @@ -96,9 +100,9 @@ Usage of rcoredump: rcoredump [options] <executable path> <timestamp of dump>
-dest string
address of the destination host (default "http://localhost:1105")
-filelog string
path of the file to log into ('-' for stdout) (default "-")
path of the file to log into ("-" for stdout) (default "-")
-src string
path of the coredump to send to the host ('-' for stdin) (default "-")
path of the coredump to send to the host ("-" for stdin) (default "-")
-syslog
output logs to syslog
-version
Expand Down
4 changes: 2 additions & 2 deletions bin/rcoredump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func (s *service) configure() {
fs.PrintDefaults()
}
fs.StringVar(&s.dest, "dest", "http://localhost:1105", "address of the destination host")
fs.StringVar(&s.src, "src", "-", "path of the coredump to send to the host ('-' for stdin)")
fs.StringVar(&s.src, "src", "-", "path of the coredump to send to the host (\"-\" for stdin)")
fs.BoolVar(&s.syslog, "syslog", false, "output logs to syslog")
fs.StringVar(&s.filelog, "filelog", "-", "path of the file to log into ('-' for stdout)")
fs.StringVar(&s.filelog, "filelog", "-", "path of the file to log into (\"-\" for stdout)")
fs.BoolVar(&s.printVersion, "version", false, "print the version of rcoredump")
fs.String("conf", "/etc/rcoredump/rcoredump.conf", "configuration file to load")
conf.Parse(fs, "conf")
Expand Down
20 changes: 19 additions & 1 deletion bin/rcoredumpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"html/template"
"io"
"io/ioutil"
"log/syslog"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -56,6 +57,8 @@ func main() {
type service struct {
// Configuration.
bind string
syslog bool
filelog string
printVersion bool
indexType string
blevePath string
Expand Down Expand Up @@ -84,6 +87,8 @@ func (s *service) configure() {

// General options.
fs.StringVar(&s.bind, "bind", "localhost:1105", "address to listen to")
fs.BoolVar(&s.syslog, "syslog", false, "output logs to syslog")
fs.StringVar(&s.filelog, "filelog", "-", "path of the file to log into (\"-\" for stdout)")
fs.BoolVar(&s.printVersion, "version", false, "print the version of rcoredumpd")

// Index options.
Expand Down Expand Up @@ -112,7 +117,20 @@ func (s *service) init() (err error) {

// Logger
s.logger = log15.New()
s.logger.SetHandler(log15.StreamHandler(os.Stdout, log15.LogfmtFormat()))

format := log15.LogfmtFormat()
var handler log15.Handler
if s.syslog {
handler, err = log15.SyslogHandler(syslog.LOG_KERN, "rcoredumpd", format)
} else if s.filelog == "-" {
handler, err = log15.StreamHandler(os.Stdout, format), nil
} else {
handler, err = log15.FileHandler(s.filelog, format)
}
if err != nil {
return err
}
s.logger.SetHandler(handler)

// Data dir
s.logger.Debug("creating data directories")
Expand Down

0 comments on commit dde02f0

Please sign in to comment.