Skip to content
Browse files

Add env variable "ODO_LOG_LEVEL" to control odo verbosity (#2351) (#2378


* Add enviroment variable "ODO_LOG_LEVEL" to control odo verbosity. Command line flag "-v", if set, will take precedence over "ODO_LOG_LEVEL"
  • Loading branch information
kanchwala-yusuf authored and openshift-merge-robot committed Nov 12, 2019
1 parent b572076 commit 5eb0ff5e73ad76322724e0cc9ef3beb9f016c72e
Showing with 10 additions and 1 deletion.
  1. +7 −0 cmd/odo/odo.go
  2. +3 −1 docs/dev/logging.adoc
@@ -43,6 +43,13 @@ func main() {

// Override the logging level by the value (if set) by the ODO_LOG_LEVEL env
// The "-v" flag set on command line will take precedence over ODO_LOG_LEVEL env
v := flag.CommandLine.Lookup("v").Value.String()
if level, ok := os.LookupEnv("ODO_LOG_LEVEL"); ok && v == "0" {
_ = flag.CommandLine.Set("v", level)

// run the completion, in case that the completion was invoked
// and ran as a completion script or handled a flag that passed
// as argument, the Run method will return true,
@@ -6,7 +6,9 @@[Glog] is used for V style logging in `o

Every `odo` command takes an optional flag `-v` that must be used with an integer log level in the range from 0-9. Any INFO severity log statement that is logged at a level lesser than or equal to the one passed with the command alongside `-v` flag will be logged to STDOUT.

All ERROR severity level log messages will always be logged regardless of the passed `v` level.
Alternatively, enviroment variable `ODO_LOG_LEVEL` can be used to set the verbosity of the log level in the integer range 0-9. The value set by `ODO_LOG_LEVEL` can be overridden by explicitly passing the `-v` command line flag to the `odo` command, in such an event `-v` flag takes precedence over the enviroment variable `ODO_LOG_LEVEL`.

All ERROR severity level log messages will always be logged regardless of the values of `v` or `ODO_LOG_LEVEL`.

== Usage

0 comments on commit 5eb0ff5

Please sign in to comment.
You can’t perform that action at this time.