make/InitSupport.gmk
changeset 35444 4d323e794486
parent 35370 f9b430645a18
child 35744 4f5e0998b6e9
--- a/make/InitSupport.gmk	Mon Feb 01 10:07:35 2016 -0800
+++ b/make/InitSupport.gmk	Tue Feb 02 15:02:55 2016 +0100
@@ -121,6 +121,23 @@
     endif
   endef
 
+  # Look for a given option in the LOG variable, and if found, set a variable
+  # and remove the option from the LOG variable
+  # $1: The option to look for
+  # $2: The option to set to "true" if the option is found
+  define ParseLogOption
+    ifneq ($$(findstring $1, $$(LOG)),)
+      $2 := true
+      # COMMA is defined in spec.gmk, but that is not included yet
+      COMMA := ,
+      # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+      LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$(strip $1),, $$(LOG)))
+      # We might have ended up with a leading comma. Remove it. Need override
+      # since LOG is set from the command line.
+      override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+    endif
+  endef
+
   define ParseLogLevel
     # Catch old-style VERBOSE= command lines.
     ifneq ($$(origin VERBOSE), undefined)
@@ -131,17 +148,12 @@
     # Setup logging according to LOG
 
     # If the "nofile" argument is given, act on it and strip it away
-    ifneq ($$(findstring nofile, $$(LOG)),)
-      LOG_NOFILE := true
-      # COMMA is defined in spec.gmk, but that is not included yet
-      COMMA := ,
-      # First try to remove ",nofile" if it exists, otherwise just remove "nofile"
-      LOG_STRIPPED := $$(subst nofile,, $$(subst $$(COMMA)nofile,, $$(LOG)))
-      # We might have ended up with a leading comma. Remove it
-      LOG_LEVEL := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
-    else
-      LOG_LEVEL := $$(LOG)
-    endif
+    $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
+
+    # If the "cmdline" argument is given, act on it and strip it away
+    $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
+
+    LOG_LEVEL := $$(LOG)
 
     ifeq ($$(LOG_LEVEL),)
       # Set LOG to "warn" as default if not set
@@ -157,7 +169,9 @@
     else ifeq ($$(LOG_LEVEL), trace)
       MAKE_LOG_FLAGS :=
     else
-      $$(info Error: LOG must be one of: warn, info, debug or trace.)
+      $$(info Error: LOG contains unknown option or log level: $$(LOG).)
+      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines)
+      $$(info and <level> is warn | info | debug | trace)
       $$(error Cannot continue)
     endif
   endef