Skip to content

Commit

Permalink
Remove --loglevel CLI flag
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Aug 4, 2022
1 parent 8390b67 commit fcdfb92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ Application Options:
--force Return zero exit status even if issues found
--color Enable colorized output
--no-color Disable colorized output
--loglevel=[trace|debug|info|warn|error] Change the loglevel
Help Options:
-h, --help Show this help message
Expand Down
8 changes: 3 additions & 5 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ func (cli *CLI) Run(args []string) int {
cli.formatter.NoColor = true
}
level := os.Getenv("TFLINT_LOG")
if opts.LogLevel != "" {
level = opts.LogLevel
// Pass log level to plugin processes
os.Setenv("TFLINT_LOG", level)
}
log.SetOutput(&logutils.LevelFilter{
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: logutils.LogLevel(strings.ToUpper(level)),
Expand Down Expand Up @@ -167,5 +162,8 @@ func unknownOptionHandler(option string, arg flags.SplitArgument, args []string)
if option == "aws-access-key" || option == "aws-secret-key" || option == "aws-profile" || option == "aws-creds-file" || option == "aws-region" {
return []string{}, fmt.Errorf("`%s` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead", option)
}
if option == "loglevel" {
return []string{}, errors.New("`loglevel` option was removed in v0.40.0. Please set `TFLINT_LOG` environment variables instead")
}
return []string{}, fmt.Errorf("`%s` is unknown option. Please run `tflint --help`", option)
}
6 changes: 6 additions & 0 deletions cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ func TestCLIRun__noIssuesFound(t *testing.T) {
Status: ExitCodeError,
Stderr: "`aws-region` option was removed in v0.23.0. AWS rules are provided by the AWS plugin, so please configure the plugin instead",
},
{
Name: "removed `loglevel` options",
Command: "./tflint --loglevel debug",
Status: ExitCodeError,
Stderr: "`loglevel` option was removed in v0.40.0. Please set `TFLINT_LOG` environment variables instead",
},
{
Name: "invalid options",
Command: "./tflint --unknown",
Expand Down
1 change: 0 additions & 1 deletion cmd/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Options struct {
Force bool `long:"force" description:"Return zero exit status even if issues found"`
Color bool `long:"color" description:"Enable colorized output"`
NoColor bool `long:"no-color" description:"Disable colorized output"`
LogLevel string `long:"loglevel" description:"Change the loglevel" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error"`
}

func (opts *Options) toConfig() *tflint.Config {
Expand Down

0 comments on commit fcdfb92

Please sign in to comment.