]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/EdkLogger.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Common / EdkLogger.py
index a3bcb3a14701eb70b5c21c78dc87179fa7922258..06da4a9d0a1d0be96994d1041be6003da66fab41 100644 (file)
-## @file
-# This file implements the log mechanism for Python tools.
-#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution.  The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-
-## Import modules
-import sys, os, logging
-import traceback
-from  BuildToolError import *
-
-## Log level constants
-DEBUG_0 = 1
-DEBUG_1 = 2
-DEBUG_2 = 3
-DEBUG_3 = 4
-DEBUG_4 = 5
-DEBUG_5 = 6
-DEBUG_6 = 7
-DEBUG_7 = 8
-DEBUG_8 = 9
-DEBUG_9 = 10
-VERBOSE = 15
-INFO    = 20
-WARN    = 30
-QUIET   = 40
-ERROR   = 50
-
-IsRaiseError = True
-
-# Tool name
-_ToolName = os.path.basename(sys.argv[0])
-
-# For validation purpose
-_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]
-
-# For DEBUG level (All DEBUG_0~9 are applicable)
-_DebugLogger = logging.getLogger("tool_debug")
-_DebugFormatter = logging.Formatter("[%(asctime)s.%(msecs)d]: %(message)s", datefmt="%H:%M:%S")
-
-# For VERBOSE, INFO, WARN level
-_InfoLogger = logging.getLogger("tool_info")
-_InfoFormatter = logging.Formatter("%(message)s")
-
-# For ERROR level
-_ErrorLogger = logging.getLogger("tool_error")
-_ErrorFormatter = logging.Formatter("%(message)s")
-
-# String templates for ERROR/WARN/DEBUG log message
-_ErrorMessageTemplate = '\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\n\t%(extra)s'
-_ErrorMessageTemplateWithoutFile = '\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s'
-_WarningMessageTemplate = '%(tool)s...\n%(file)s(%(line)s): warning: %(msg)s'
-_WarningMessageTemplateWithoutFile = '%(tool)s: : warning: %(msg)s'
-_DebugMessageTemplate = '%(file)s(%(line)s): debug: \n    %(msg)s'
-
-#
-# Flag used to take WARN as ERROR.
-# By default, only ERROR message will break the tools execution.
-#
-_WarningAsError = False
-
-## Log debug message
-#
-#   @param  Level       DEBUG level (DEBUG0~9)
-#   @param  Message     Debug information
-#   @param  ExtraData   More information associated with "Message"
-#
-def debug(Level, Message, ExtraData=None):
-    if _DebugLogger.level > Level:
-        return
-    if Level > DEBUG_9:
-        return
-
-    # Find out the caller method information
-    CallerStack = traceback.extract_stack()[-2]
-    TemplateDict = {
-        "file"      : CallerStack[0],
-        "line"      : CallerStack[1],
-        "msg"       : Message,
-    }
-
-    if ExtraData != None:
-        LogText = _DebugMessageTemplate % TemplateDict + "\n    %s" % ExtraData
-    else:
-        LogText = _DebugMessageTemplate % TemplateDict
-
-    _DebugLogger.log(Level, LogText)
-
-## Log verbose message
-#
-#   @param  Message     Verbose information
-#
-def verbose(Message):
-    return _InfoLogger.log(VERBOSE, Message)
-
-## Log warning message
-#
-#   Warning messages are those which might be wrong but won't fail the tool.
-#
-#   @param  ToolName    The name of the tool. If not given, the name of caller
-#                       method will be used.
-#   @param  Message     Warning information
-#   @param  File        The name of file which caused the warning.
-#   @param  Line        The line number in the "File" which caused the warning.
-#   @param  ExtraData   More information associated with "Message"
-#
-def warn(ToolName, Message, File=None, Line=None, ExtraData=None):
-    if _InfoLogger.level > WARN:
-        return
-
-    # if no tool name given, use caller's source file name as tool name
-    if ToolName == None or ToolName == "":
-        ToolName = os.path.basename(traceback.extract_stack()[-2][0])
-
-    if Line == None:
-        Line = "..."
-    else:
-        Line = "%d" % Line
-
-    TemplateDict = {
-        "tool"      : ToolName,
-        "file"      : File,
-        "line"      : Line,
-        "msg"       : Message,
-    }
-
-    if File != None:
-        LogText = _WarningMessageTemplate % TemplateDict
-    else:
-        LogText = _WarningMessageTemplateWithoutFile % TemplateDict
-
-    if ExtraData != None:
-        LogText += "\n    %s" % ExtraData
-
-    _InfoLogger.log(WARN, LogText)
-
-    # Raise an execption if indicated
-    if _WarningAsError == True:
-        raise FatalError(WARNING_AS_ERROR)
-
-## Log INFO message
-info    = _InfoLogger.info
-
-## Log ERROR message
-#
-#   Once an error messages is logged, the tool's execution will be broken by raising
-# an execption. If you don't want to break the execution later, you can give
-# "RaiseError" with "False" value.
-#
-#   @param  ToolName    The name of the tool. If not given, the name of caller
-#                       method will be used.
-#   @param  ErrorCode   The error code
-#   @param  Message     Warning information
-#   @param  File        The name of file which caused the error.
-#   @param  Line        The line number in the "File" which caused the warning.
-#   @param  ExtraData   More information associated with "Message"
-#   @param  RaiseError  Raise an exception to break the tool's executuion if
-#                       it's True. This is the default behavior.
-#
-def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=None, RaiseError=IsRaiseError):
-    if Line == None:
-        Line = "..."
-    else:
-        Line = "%d" % Line
-
-    if Message == None:
-        if ErrorCode in gErrorMessage:
-            Message = gErrorMessage[ErrorCode]
-        else:
-            Message = gErrorMessage[UNKNOWN_ERROR]
-
-    if ExtraData == None:
-        ExtraData = ""
-
-    TemplateDict = {
-        "tool"      : _ToolName,
-        "file"      : File,
-        "line"      : Line,
-        "errorcode" : ErrorCode,
-        "msg"       : Message,
-        "extra"     : ExtraData
-    }
-
-    if File != None:
-        LogText =  _ErrorMessageTemplate % TemplateDict
-    else:
-        LogText = _ErrorMessageTemplateWithoutFile % TemplateDict
-
-    _ErrorLogger.log(ERROR, LogText)
-    if RaiseError:
-        raise FatalError(ErrorCode)
-
-# Log information which should be always put out
-quiet   = _ErrorLogger.error
-
-## 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)
-
-## Set log level
-#
-#   @param  Level   One of log level in _LogLevel
-def SetLevel(Level):
-    if Level not in _LogLevels:
-        info("Not supported log level (%d). Use default level instead." % Level)
-        Level = INFO
-    _DebugLogger.setLevel(Level)
-    _InfoLogger.setLevel(Level)
-    _ErrorLogger.setLevel(Level)
-
-## Get current log level
-def GetLevel():
-    return _InfoLogger.getEffectiveLevel()
-
-## Raise up warning as error
-def SetWarningAsError():
-    global _WarningAsError
-    _WarningAsError = True
-
-## Specify a file to store the log message as well as put on console
-#
-#   @param  LogFile     The file path used to store the log message
-#
-def SetLogFile(LogFile):
-    if os.path.exists(LogFile):
-        os.remove(LogFile)
-
-    _Ch = logging.FileHandler(LogFile)
-    _Ch.setFormatter(_DebugFormatter)
-    _DebugLogger.addHandler(_Ch)
-
-    _Ch= logging.FileHandler(LogFile)
-    _Ch.setFormatter(_InfoFormatter)
-    _InfoLogger.addHandler(_Ch)
-
-    _Ch = logging.FileHandler(LogFile)
-    _Ch.setFormatter(_ErrorFormatter)
-    _ErrorLogger.addHandler(_Ch)
-
-if __name__ == '__main__':
-    pass
-
+## @file\r
+# This file implements the log mechanism for Python tools.\r
+#\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+\r
+# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved.\r
+#\r
+# Permission to use, copy, modify, and distribute this software and its\r
+# documentation for any purpose and without fee is hereby granted,\r
+# provided that the above copyright notice appear in all copies and that\r
+# both that copyright notice and this permission notice appear in\r
+# supporting documentation, and that the name of Vinay Sajip\r
+# not be used in advertising or publicity pertaining to distribution\r
+# of the software without specific, written prior permission.\r
+# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\r
+# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL\r
+# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\r
+# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\r
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\r
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r
+# This copyright is for QueueHandler.\r
+\r
+## Import modules\r
+from __future__ import absolute_import\r
+import Common.LongFilePathOs as os, sys, logging\r
+import traceback\r
+from  .BuildToolError import *\r
+try:\r
+    from logging.handlers import QueueHandler\r
+except:\r
+    class QueueHandler(logging.Handler):\r
+        """\r
+        This handler sends events to a queue. Typically, it would be used together\r
+        with a multiprocessing Queue to centralise logging to file in one process\r
+        (in a multi-process application), so as to avoid file write contention\r
+        between processes.\r
+\r
+        This code is new in Python 3.2, but this class can be copy pasted into\r
+        user code for use with earlier Python versions.\r
+        """\r
+\r
+        def __init__(self, queue):\r
+            """\r
+            Initialise an instance, using the passed queue.\r
+            """\r
+            logging.Handler.__init__(self)\r
+            self.queue = queue\r
+\r
+        def enqueue(self, record):\r
+            """\r
+            Enqueue a record.\r
+\r
+            The base implementation uses put_nowait. You may want to override\r
+            this method if you want to use blocking, timeouts or custom queue\r
+            implementations.\r
+            """\r
+            self.queue.put_nowait(record)\r
+\r
+        def prepare(self, record):\r
+            """\r
+            Prepares a record for queuing. The object returned by this method is\r
+            enqueued.\r
+\r
+            The base implementation formats the record to merge the message\r
+            and arguments, and removes unpickleable items from the record\r
+            in-place.\r
+\r
+            You might want to override this method if you want to convert\r
+            the record to a dict or JSON string, or send a modified copy\r
+            of the record while leaving the original intact.\r
+            """\r
+            # The format operation gets traceback text into record.exc_text\r
+            # (if there's exception data), and also returns the formatted\r
+            # message. We can then use this to replace the original\r
+            # msg + args, as these might be unpickleable. We also zap the\r
+            # exc_info and exc_text attributes, as they are no longer\r
+            # needed and, if not None, will typically not be pickleable.\r
+            msg = self.format(record)\r
+            record.message = msg\r
+            record.msg = msg\r
+            record.args = None\r
+            record.exc_info = None\r
+            record.exc_text = None\r
+            return record\r
+\r
+        def emit(self, record):\r
+            """\r
+            Emit a record.\r
+\r
+            Writes the LogRecord to the queue, preparing it for pickling first.\r
+            """\r
+            try:\r
+                self.enqueue(self.prepare(record))\r
+            except Exception:\r
+                self.handleError(record)\r
+class BlockQueueHandler(QueueHandler):\r
+    def enqueue(self, record):\r
+        self.queue.put(record,True)\r
+## Log level constants\r
+DEBUG_0 = 1\r
+DEBUG_1 = 2\r
+DEBUG_2 = 3\r
+DEBUG_3 = 4\r
+DEBUG_4 = 5\r
+DEBUG_5 = 6\r
+DEBUG_6 = 7\r
+DEBUG_7 = 8\r
+DEBUG_8 = 9\r
+DEBUG_9 = 10\r
+VERBOSE = 15\r
+INFO    = 20\r
+WARN    = 30\r
+QUIET   = 40\r
+ERROR   = 50\r
+SILENT  = 99\r
+\r
+IsRaiseError = True\r
+\r
+# Tool name\r
+_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,\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
+_DebugFormatter = logging.Formatter("[%(asctime)s.%(msecs)d]: %(message)s", datefmt="%H:%M:%S")\r
+\r
+# For VERBOSE, INFO, WARN level\r
+_InfoLogger = logging.getLogger("tool_info")\r
+_InfoFormatter = logging.Formatter("%(message)s")\r
+\r
+# For ERROR level\r
+_ErrorLogger = logging.getLogger("tool_error")\r
+_ErrorFormatter = logging.Formatter("%(message)s")\r
+\r
+# String templates for ERROR/WARN/DEBUG log message\r
+_ErrorMessageTemplate = '\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\n\t%(extra)s'\r
+_ErrorMessageTemplateWithoutFile = '\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s'\r
+_WarningMessageTemplate = '%(tool)s...\n%(file)s(%(line)s): warning: %(msg)s'\r
+_WarningMessageTemplateWithoutFile = '%(tool)s: : warning: %(msg)s'\r
+_DebugMessageTemplate = '%(file)s(%(line)s): debug: \n    %(msg)s'\r
+\r
+#\r
+# Flag used to take WARN as ERROR.\r
+# By default, only ERROR message will break the tools execution.\r
+#\r
+_WarningAsError = False\r
+\r
+## Log debug message\r
+#\r
+#   @param  Level       DEBUG level (DEBUG0~9)\r
+#   @param  Message     Debug information\r
+#   @param  ExtraData   More information associated with "Message"\r
+#\r
+def debug(Level, Message, ExtraData=None):\r
+    if _DebugLogger.level > Level:\r
+        return\r
+    if Level > DEBUG_9:\r
+        return\r
+\r
+    # Find out the caller method information\r
+    CallerStack = traceback.extract_stack()[-2]\r
+    TemplateDict = {\r
+        "file"      : CallerStack[0],\r
+        "line"      : CallerStack[1],\r
+        "msg"       : Message,\r
+    }\r
+\r
+    if ExtraData is not None:\r
+        LogText = _DebugMessageTemplate % TemplateDict + "\n    %s" % ExtraData\r
+    else:\r
+        LogText = _DebugMessageTemplate % TemplateDict\r
+\r
+    _DebugLogger.log(Level, LogText)\r
+\r
+## Log verbose message\r
+#\r
+#   @param  Message     Verbose information\r
+#\r
+def verbose(Message):\r
+    return _InfoLogger.log(VERBOSE, Message)\r
+\r
+## Log warning message\r
+#\r
+#   Warning messages are those which might be wrong but won't fail the tool.\r
+#\r
+#   @param  ToolName    The name of the tool. If not given, the name of caller\r
+#                       method will be used.\r
+#   @param  Message     Warning information\r
+#   @param  File        The name of file which caused the warning.\r
+#   @param  Line        The line number in the "File" which caused the warning.\r
+#   @param  ExtraData   More information associated with "Message"\r
+#\r
+def warn(ToolName, Message, File=None, Line=None, ExtraData=None):\r
+    if _InfoLogger.level > WARN:\r
+        return\r
+\r
+    # if no tool name given, use caller's source file name as tool name\r
+    if ToolName is None or ToolName == "":\r
+        ToolName = os.path.basename(traceback.extract_stack()[-2][0])\r
+\r
+    if Line is None:\r
+        Line = "..."\r
+    else:\r
+        Line = "%d" % Line\r
+\r
+    TemplateDict = {\r
+        "tool"      : ToolName,\r
+        "file"      : File,\r
+        "line"      : Line,\r
+        "msg"       : Message,\r
+    }\r
+\r
+    if File is not None:\r
+        LogText = _WarningMessageTemplate % TemplateDict\r
+    else:\r
+        LogText = _WarningMessageTemplateWithoutFile % TemplateDict\r
+\r
+    if ExtraData is not None:\r
+        LogText += "\n    %s" % ExtraData\r
+\r
+    _InfoLogger.log(WARN, LogText)\r
+\r
+    # Raise an exception if indicated\r
+    if _WarningAsError == True:\r
+        raise FatalError(WARNING_AS_ERROR)\r
+\r
+## Log INFO message\r
+info    = _InfoLogger.info\r
+\r
+## Log ERROR message\r
+#\r
+#   Once an error messages is logged, the tool's execution will be broken by raising\r
+# an exception. If you don't want to break the execution later, you can give\r
+# "RaiseError" with "False" value.\r
+#\r
+#   @param  ToolName    The name of the tool. If not given, the name of caller\r
+#                       method will be used.\r
+#   @param  ErrorCode   The error code\r
+#   @param  Message     Warning information\r
+#   @param  File        The name of file which caused the error.\r
+#   @param  Line        The line number in the "File" which caused the warning.\r
+#   @param  ExtraData   More information associated with "Message"\r
+#   @param  RaiseError  Raise an exception to break the tool's execution if\r
+#                       it's True. This is the default behavior.\r
+#\r
+def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=None, RaiseError=IsRaiseError):\r
+    if Line is None:\r
+        Line = "..."\r
+    else:\r
+        Line = "%d" % Line\r
+\r
+    if Message is None:\r
+        if ErrorCode in gErrorMessage:\r
+            Message = gErrorMessage[ErrorCode]\r
+        else:\r
+            Message = gErrorMessage[UNKNOWN_ERROR]\r
+\r
+    if ExtraData is None:\r
+        ExtraData = ""\r
+\r
+    TemplateDict = {\r
+        "tool"      : _ToolName,\r
+        "file"      : File,\r
+        "line"      : Line,\r
+        "errorcode" : ErrorCode,\r
+        "msg"       : Message,\r
+        "extra"     : ExtraData\r
+    }\r
+\r
+    if File is not None:\r
+        LogText =  _ErrorMessageTemplate % TemplateDict\r
+    else:\r
+        LogText = _ErrorMessageTemplateWithoutFile % TemplateDict\r
+\r
+    _ErrorLogger.log(ERROR, LogText)\r
+\r
+    if RaiseError and IsRaiseError:\r
+        raise FatalError(ErrorCode)\r
+\r
+# Log information which should be always put out\r
+quiet   = _ErrorLogger.error\r
+\r
+## Initialize log system\r
+def LogClientInitialize(log_q):\r
+    #\r
+    # Since we use different format to log different levels of message into different\r
+    # place (stdout or stderr), we have to use different "Logger" objects to do this.\r
+    #\r
+    # For DEBUG level (All DEBUG_0~9 are applicable)\r
+    _DebugLogger.setLevel(INFO)\r
+    _DebugChannel = BlockQueueHandler(log_q)\r
+    _DebugChannel.setFormatter(_DebugFormatter)\r
+    _DebugLogger.addHandler(_DebugChannel)\r
+\r
+    # For VERBOSE, INFO, WARN level\r
+    _InfoLogger.setLevel(INFO)\r
+    _InfoChannel = BlockQueueHandler(log_q)\r
+    _InfoChannel.setFormatter(_InfoFormatter)\r
+    _InfoLogger.addHandler(_InfoChannel)\r
+\r
+    # For ERROR level\r
+    _ErrorLogger.setLevel(INFO)\r
+    _ErrorCh = BlockQueueHandler(log_q)\r
+    _ErrorCh.setFormatter(_ErrorFormatter)\r
+    _ErrorLogger.addHandler(_ErrorCh)\r
+\r
+## Set log level\r
+#\r
+#   @param  Level   One of log level in _LogLevel\r
+def SetLevel(Level):\r
+    if Level not in _LogLevels:\r
+        info("Not supported log level (%d). Use default level instead." % Level)\r
+        Level = INFO\r
+    _DebugLogger.setLevel(Level)\r
+    _InfoLogger.setLevel(Level)\r
+    _ErrorLogger.setLevel(Level)\r
+\r
+## Initialize log system\r
+def Initialize():\r
+    #\r
+    # Since we use different format to log different levels of message into different\r
+    # place (stdout or stderr), we have to use different "Logger" objects to do this.\r
+    #\r
+    # For DEBUG level (All DEBUG_0~9 are applicable)\r
+    _DebugLogger.setLevel(INFO)\r
+    _DebugChannel = logging.StreamHandler(sys.stdout)\r
+    _DebugChannel.setFormatter(_DebugFormatter)\r
+    _DebugLogger.addHandler(_DebugChannel)\r
+\r
+    # For VERBOSE, INFO, WARN level\r
+    _InfoLogger.setLevel(INFO)\r
+    _InfoChannel = logging.StreamHandler(sys.stdout)\r
+    _InfoChannel.setFormatter(_InfoFormatter)\r
+    _InfoLogger.addHandler(_InfoChannel)\r
+\r
+    # For ERROR level\r
+    _ErrorLogger.setLevel(INFO)\r
+    _ErrorCh = logging.StreamHandler(sys.stderr)\r
+    _ErrorCh.setFormatter(_ErrorFormatter)\r
+    _ErrorLogger.addHandler(_ErrorCh)\r
+\r
+def InitializeForUnitTest():\r
+    Initialize()\r
+    SetLevel(SILENT)\r
+\r
+## Get current log level\r
+def GetLevel():\r
+    return _InfoLogger.getEffectiveLevel()\r
+\r
+## Raise up warning as error\r
+def SetWarningAsError():\r
+    global _WarningAsError\r
+    _WarningAsError = True\r
+\r
+## Specify a file to store the log message as well as put on console\r
+#\r
+#   @param  LogFile     The file path used to store the log message\r
+#\r
+def SetLogFile(LogFile):\r
+    if os.path.exists(LogFile):\r
+        os.remove(LogFile)\r
+\r
+    _Ch = logging.FileHandler(LogFile)\r
+    _Ch.setFormatter(_DebugFormatter)\r
+    _DebugLogger.addHandler(_Ch)\r
+\r
+    _Ch= logging.FileHandler(LogFile)\r
+    _Ch.setFormatter(_InfoFormatter)\r
+    _InfoLogger.addHandler(_Ch)\r
+\r
+    _Ch = logging.FileHandler(LogFile)\r
+    _Ch.setFormatter(_ErrorFormatter)\r
+    _ErrorLogger.addHandler(_Ch)\r
+\r
+if __name__ == '__main__':\r
+    pass\r
+\r