Skip to content

Commit

Permalink
feat: add feature that can select log format by env
Browse files Browse the repository at this point in the history
  • Loading branch information
namkyu1999 committed Apr 7, 2023
1 parent 6f1893f commit b7aed50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion litmus-portal/graphql-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ import (
)

func init() {
err := envconfig.Process("", &utils.Config)

// Default log format is text
if utils.Config.LitmusChaosServerLogFormat == "json" {
log.SetFormatter(&log.JSONFormatter{})
}

log.Infof("Go Version: %s", runtime.Version())
log.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)

err := envconfig.Process("", &utils.Config)
if err != nil {
log.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions litmus-portal/graphql-server/utils/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Configurations struct {
LitmusChaosOperatorImage string `required:"true" split_words:"true"`
LitmusChaosRunnerImage string `required:"true" split_words:"true"`
LitmusChaosExporterImage string `required:"true" split_words:"true"`
LitmusChaosServerLogFormat string `split_words:"true" default:"text"`
ContainerRuntimeExecutor string `required:"true" split_words:"true"`
HubBranchName string `required:"true" split_words:"true"`
WorkflowHelperImageVersion string `required:"true" split_words:"true"`
Expand Down

0 comments on commit b7aed50

Please sign in to comment.