Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add environment variable for writing tracing information to a file #52

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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