Skip to content

Commit

Permalink
Removed the --logformat flag
Browse files Browse the repository at this point in the history
Removed the deprecated --logformat flag, the --log-format alternative
should be used.
  • Loading branch information
codebien committed Nov 20, 2023
1 parent 7a30976 commit a087d42
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
5 changes: 0 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,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

0 comments on commit a087d42

Please sign in to comment.