]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/EdkLogger: Support unit tests with a SILENT log level
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 23 Jun 2015 23:34:09 +0000 (23:34 +0000)
committerjljusten <jljusten@Edk2>
Tue, 23 Jun 2015 23:34:09 +0000 (23:34 +0000)
This allows the unit tests to run without the errors logging to the
screen.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17692 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/Python/Common/EdkLogger.py

index f048b619e403170953d0cf9335cad8307d1a8320..ac1c8edc4fe2fd8332d78ff48808020e66d63147 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file implements the log mechanism for Python tools.\r
 #\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -32,6 +32,7 @@ INFO    = 20
 WARN    = 30\r
 QUIET   = 40\r
 ERROR   = 50\r
+SILENT  = 99\r
 \r
 IsRaiseError = True\r
 \r
@@ -39,7 +40,9 @@ IsRaiseError = True
 _ToolName = os.path.basename(sys.argv[0])\r
 \r
 # For validation purpose\r
-_LogLevels = [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5, DEBUG_6, DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO, ERROR, QUIET]\r
+_LogLevels = [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5,\r
+              DEBUG_6, DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO,\r
+              ERROR, QUIET, SILENT]\r
 \r
 # For DEBUG level (All DEBUG_0~9 are applicable)\r
 _DebugLogger = logging.getLogger("tool_debug")\r
@@ -235,6 +238,10 @@ def SetLevel(Level):
     _InfoLogger.setLevel(Level)\r
     _ErrorLogger.setLevel(Level)\r
 \r
+def InitializeForUnitTest():\r
+    Initialize()\r
+    SetLevel(SILENT)\r
+\r
 ## Get current log level\r
 def GetLevel():\r
     return _InfoLogger.getEffectiveLevel()\r