Skip to content

Commit

Permalink
Merge pull request #52 from ipfs/feat/tracing-file
Browse files Browse the repository at this point in the history
add environment variable for writing tracing information to a file
  • Loading branch information
Stebalien authored Oct 30, 2018
2 parents 5e6883f + 9f93581 commit 4b03637
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion oldlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"

tracer "github.com/ipfs/go-log/tracer"
lwriter "github.com/ipfs/go-log/writer"

colorable "github.com/mattn/go-colorable"
opentrace "github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -36,7 +37,8 @@ const (
envLogging = "IPFS_LOGGING"
envLoggingFmt = "IPFS_LOGGING_FMT"

envLoggingFile = "GOLOG_FILE" // /path/to/file
envLoggingFile = "GOLOG_FILE" // /path/to/file
envTracingFile = "GOLOG_TRACING_FILE" // /path/to/file
)

// ErrNoSuchLogger is returned when the util pkg is asked for a non existant logger
Expand Down Expand Up @@ -93,6 +95,15 @@ func SetupLogging() {
opentrace.SetGlobalTracer(lgblTracer)

SetAllLoggers(lvl)

if tracingfp := os.Getenv(envTracingFile); len(tracingfp) > 0 {
f, err := os.Create(tracingfp)
if err != nil {
log.Error("failed to create tracing file: %s", tracingfp)
} else {
lwriter.WriterGroup.AddWriter(f)
}
}
}

// SetDebugLogging calls SetAllLoggers with logging.DEBUG
Expand Down

0 comments on commit 4b03637

Please sign in to comment.