diff options
Diffstat (limited to 'BaseTools/Source/Python/Common/EdkLogger.py')
-rw-r--r-- | BaseTools/Source/Python/Common/EdkLogger.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py index ae2070bebb..f6a5e3b4da 100644 --- a/BaseTools/Source/Python/Common/EdkLogger.py +++ b/BaseTools/Source/Python/Common/EdkLogger.py @@ -10,6 +10,7 @@ from __future__ import absolute_import import Common.LongFilePathOs as os, sys, logging
import traceback
from .BuildToolError import *
+import logging.handlers
## Log level constants
DEBUG_0 = 1
@@ -200,26 +201,26 @@ def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=Non quiet = _ErrorLogger.error
## Initialize log system
-def Initialize():
+def LogClientInitialize(log_q):
#
# Since we use different format to log different levels of message into different
# place (stdout or stderr), we have to use different "Logger" objects to do this.
#
# For DEBUG level (All DEBUG_0~9 are applicable)
_DebugLogger.setLevel(INFO)
- _DebugChannel = logging.StreamHandler(sys.stdout)
+ _DebugChannel = logging.handlers.QueueHandler(log_q)
_DebugChannel.setFormatter(_DebugFormatter)
_DebugLogger.addHandler(_DebugChannel)
# For VERBOSE, INFO, WARN level
_InfoLogger.setLevel(INFO)
- _InfoChannel = logging.StreamHandler(sys.stdout)
+ _InfoChannel = logging.handlers.QueueHandler(log_q)
_InfoChannel.setFormatter(_InfoFormatter)
_InfoLogger.addHandler(_InfoChannel)
# For ERROR level
_ErrorLogger.setLevel(INFO)
- _ErrorCh = logging.StreamHandler(sys.stderr)
+ _ErrorCh = logging.handlers.QueueHandler(log_q)
_ErrorCh.setFormatter(_ErrorFormatter)
_ErrorLogger.addHandler(_ErrorCh)
@@ -234,6 +235,30 @@ def SetLevel(Level): _InfoLogger.setLevel(Level)
_ErrorLogger.setLevel(Level)
+## Initialize log system
+def Initialize():
+ #
+ # Since we use different format to log different levels of message into different
+ # place (stdout or stderr), we have to use different "Logger" objects to do this.
+ #
+ # For DEBUG level (All DEBUG_0~9 are applicable)
+ _DebugLogger.setLevel(INFO)
+ _DebugChannel = logging.StreamHandler(sys.stdout)
+ _DebugChannel.setFormatter(_DebugFormatter)
+ _DebugLogger.addHandler(_DebugChannel)
+
+ # For VERBOSE, INFO, WARN level
+ _InfoLogger.setLevel(INFO)
+ _InfoChannel = logging.StreamHandler(sys.stdout)
+ _InfoChannel.setFormatter(_InfoFormatter)
+ _InfoLogger.addHandler(_InfoChannel)
+
+ # For ERROR level
+ _ErrorLogger.setLevel(INFO)
+ _ErrorCh = logging.StreamHandler(sys.stderr)
+ _ErrorCh.setFormatter(_ErrorFormatter)
+ _ErrorLogger.addHandler(_ErrorCh)
+
def InitializeForUnitTest():
Initialize()
SetLevel(SILENT)
|