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

fix(upgrade): add log-level option #19967

Merged
merged 5 commits into from
Nov 10, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
1. [19960](https://github.com/influxdata/influxdb/pull/19960): Remove bucket and mapping auto-creation from v1 /write API
1. [19972](https://github.com/influxdata/influxdb/pull/19972): Remove unused 'influx-command-path' option from upgrade command
1. [19969](https://github.com/influxdata/influxdb/pull/19969): Check if CLI configs file already exists during upgrade
1. [19967](https://github.com/influxdata/influxdb/pull/19967): Add 'log-level' option to upgrade command

## v2.0.0-rc.4 [2020-11-05]

Expand Down
17 changes: 16 additions & 1 deletion cmd/influxd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/influxdata/influxdb/v2/v1/services/meta/filestore"
"github.com/spf13/cobra"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

// Simplified 1.x config.
Expand Down Expand Up @@ -112,7 +113,9 @@ var options = struct {
// verbose output
verbose bool

logPath string
// logging
logLevel string
logPath string

force bool
}{}
Expand Down Expand Up @@ -233,6 +236,12 @@ func NewCommand() *cobra.Command {
Default: influxConfigPathV1(),
Desc: "optional: Custom InfluxDB 1.x config file path, else the default config file",
},
{
DestP: &options.logLevel,
Flag: "log-level",
Default: zapcore.InfoLevel.String(),
Desc: "supported log levels are debug, info, warn and error",
},
{
DestP: &options.logPath,
Flag: "log-path",
Expand Down Expand Up @@ -299,8 +308,14 @@ func runUpgradeE(*cobra.Command, []string) error {
fluxInitialized = true
}

var lvl zapcore.Level
if err := lvl.Set(options.logLevel); err != nil {
return errors.New("unknown log level; supported levels are debug, info, warn and error")
}

ctx := context.Background()
config := zap.NewProductionConfig()
config.Level = zap.NewAtomicLevelAt(lvl)
config.OutputPaths = append(config.OutputPaths, options.logPath)
config.ErrorOutputPaths = append(config.ErrorOutputPaths, options.logPath)
log, err := config.Build()
Expand Down