fix(upgrade): add log-level CLI option (#19967)
Co-authored-by: Daniel Moran <danxmoran@gmail.com>pull/19988/head
parent
c4eb6290f0
commit
2982701d01
|
@ -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]
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -112,7 +113,9 @@ var options = struct {
|
|||
// verbose output
|
||||
verbose bool
|
||||
|
||||
logPath string
|
||||
// logging
|
||||
logLevel string
|
||||
logPath string
|
||||
|
||||
force bool
|
||||
}{}
|
||||
|
@ -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",
|
||||
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue