mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-04-29 12:35:01 +08:00
* added log-level flag * fix up the colors * fix description
This commit is contained in:
committed by
Shahidh K Muhammed
parent
4aef5b4c26
commit
7f06470082
13
cli/cli.go
13
cli/cli.go
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/briandowns/spinner"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/hasura/graphql-engine/cli/version"
|
||||
colorable "github.com/mattn/go-colorable"
|
||||
"github.com/mattn/go-colorable"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
@@ -171,6 +171,9 @@ type ExecutionContext struct {
|
||||
// LogLevel indicates the logrus default logging level
|
||||
LogLevel string
|
||||
|
||||
// NoColor indicates if the outputs shouldn't be colorized
|
||||
NoColor bool
|
||||
|
||||
// Telemetry collects the telemetry data throughout the execution
|
||||
Telemetry *telemetry.Data
|
||||
|
||||
@@ -343,6 +346,7 @@ func (ec *ExecutionContext) Spin(message string) {
|
||||
func (ec *ExecutionContext) setupLogger() {
|
||||
if ec.Logger == nil {
|
||||
logger := logrus.New()
|
||||
|
||||
logger.Formatter = &logrus.TextFormatter{
|
||||
ForceColors: true,
|
||||
DisableTimestamp: true,
|
||||
@@ -351,6 +355,13 @@ func (ec *ExecutionContext) setupLogger() {
|
||||
ec.Logger = logger
|
||||
}
|
||||
|
||||
if ec.NoColor {
|
||||
ec.Logger.Formatter = &logrus.TextFormatter{
|
||||
DisableColors: true,
|
||||
DisableTimestamp: true,
|
||||
}
|
||||
}
|
||||
|
||||
if ec.LogLevel != "" {
|
||||
level, err := logrus.ParseLevel(ec.LogLevel)
|
||||
if err != nil {
|
||||
|
||||
@@ -70,6 +70,7 @@ func init() {
|
||||
f.StringVar(&ec.LogLevel, "log-level", "INFO", "log level (DEBUG, INFO, WARN, ERROR, FATAL)")
|
||||
f.StringVar(&ec.ExecutionDirectory, "project", "", "directory where commands are executed (default: current dir)")
|
||||
f.BoolVar(&ec.SkipUpdateCheck, "skip-update-check", false, "Skip automatic update check on command execution")
|
||||
f.BoolVar(&ec.NoColor, "no-color", false, "do not colorize output (default: false)")
|
||||
}
|
||||
|
||||
// Execute executes the command and returns the error
|
||||
|
||||
Reference in New Issue
Block a user