Skip to content

e2e: log to a file instead of stdout #1607

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

Closed
Closed
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
6 changes: 6 additions & 0 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ func TestMain(m *testing.M) {

flag.Parse()

logFile, err := os.Create("ramentest.log")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"e2e.log"?

I'm not sure this should be the default. Logging to stdout is very easy to use and our log is not very large.

Maybe add --logfile option?

./run.sh -logfile e2e.log

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also always log to file regardless of stdout/stderr. This makes it easier to use the log after running other commands with lot of output.

If we always log to file, maybe we can use much less detailed log to stderr, maybe only the normal test output.

I also want to always keep drenv log in standard location to avoid the issue of not having logs to debug issues like this:
https://cloud-native.slack.com/archives/C043N6ZFV9S/p1732122420443799

if err != nil {
panic(err)
}

log := zap.New(zap.UseFlagOptions(&zap.Options{
Development: true,
ZapOpts: []uberzap.Option{
uberzap.AddCaller(),
},
TimeEncoder: zapcore.ISO8601TimeEncoder,
DestWriter: logFile,
}))

util.Ctx, err = util.NewContext(&log, util.ConfigFile)
Expand Down
Loading