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

Remove the --logformat flag #3389

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ func rootCmdPersistentFlagSet(gs *state.GlobalState) *pflag.FlagSet {
"change the output for k6 logs, possible values are stderr,stdout,none,loki[=host:port],file[=./path.fileformat]")
flags.Lookup("log-output").DefValue = gs.DefaultFlags.LogOutput

flags.StringVar(&gs.Flags.LogFormat, "logformat", gs.Flags.LogFormat, "log output format")
oldLogFormat := flags.Lookup("logformat")
oldLogFormat.Hidden = true
oldLogFormat.Deprecated = "log-format"
oldLogFormat.DefValue = gs.DefaultFlags.LogFormat
flags.StringVar(&gs.Flags.LogFormat, "log-format", gs.Flags.LogFormat, "log output format")
flags.Lookup("log-format").DefValue = gs.DefaultFlags.LogFormat

Expand Down
25 changes: 0 additions & 25 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"bytes"
"testing"

"github.com/sirupsen/logrus"
Expand All @@ -16,30 +15,6 @@ func TestMain(m *testing.M) {
tests.Main(m)
}

func TestDeprecatedOptionWarning(t *testing.T) {
t.Parallel()

ts := tests.NewGlobalTestState(t)
ts.CmdArgs = []string{"k6", "--logformat", "json", "run", "-"}
ts.Stdin = bytes.NewBuffer([]byte(`
console.log('foo');
export default function() { console.log('bar'); };
`))

newRootCommand(ts.GlobalState).execute()

logMsgs := ts.LoggerHook.Drain()
assert.True(t, testutils.LogContains(logMsgs, logrus.InfoLevel, "foo"))
assert.True(t, testutils.LogContains(logMsgs, logrus.InfoLevel, "bar"))
assert.Contains(t, ts.Stderr.String(), `"level":"info","msg":"foo","source":"console"`)
assert.Contains(t, ts.Stderr.String(), `"level":"info","msg":"bar","source":"console"`)

// TODO: after we get rid of cobra, actually emit this message to stderr
// and, ideally, through the log, not just print it...
assert.False(t, testutils.LogContains(logMsgs, logrus.InfoLevel, "logformat"))
assert.Contains(t, ts.Stdout.String(), `--logformat has been deprecated`)
}

func TestPanicHandling(t *testing.T) {
t.Parallel()

Expand Down