-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Introduce logging level configuration #514
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
|
@@ -45,7 +46,6 @@ func main() { | |
var serverChannel = make(chan os.Signal, 0) | ||
signal.Notify(serverChannel, os.Interrupt, syscall.SIGTERM) | ||
|
||
logger, _ := zap.NewProduction() | ||
casOptions := casFlags.NewOptions("cassandra", "cassandra.archive") | ||
esOptions := esFlags.NewOptions("es", "es.archive") | ||
v := viper.New() | ||
|
@@ -54,10 +54,18 @@ func main() { | |
Use: "jaeger-query", | ||
Short: "Jaeger query is a service to access tracing data", | ||
Long: `Jaeger query is a service to access tracing data and host UI.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
flags.TryLoadConfigFile(v, logger) | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
err := flags.TryLoadConfigFile(v) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sFlags := new(flags.SharedFlags).InitFromViper(v) | ||
logger, err := sFlags.NewLogger(zap.NewProductionConfig()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
casOptions.InitFromViper(v) | ||
esOptions.InitFromViper(v) | ||
queryOpts := new(builder.QueryOptions).InitFromViper(v) | ||
|
@@ -119,6 +127,7 @@ func main() { | |
case <-serverChannel: | ||
logger.Info("Jaeger Query is finishing") | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
|
@@ -135,7 +144,8 @@ func main() { | |
) | ||
|
||
if error := command.Execute(); error != nil { | ||
logger.Fatal(error.Error()) | ||
fmt.Println(error.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unfortunate, because a logger may print the error quite differently, e.g. with a stack trace, write to file, report to Sentry, etc. If we guaranteed that the command only returned errors when it can't init the logger, then it wouldn't be too bad, but I don't think this is generally the case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This statement is invoked when:
Other solution might be to use a default logger here. |
||
os.Exit(1) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch