]>
Commit | Line | Data |
---|---|---|
7ccc9c95 YZ |
1 | ## @file\r |
2 | #\r | |
3 | # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
4 | #\r | |
5 | # This program and the accompanying materials are licensed and made available\r | |
6 | # under the terms and conditions of the BSD License which accompanies this\r | |
7 | # distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | #\r | |
13 | \r | |
14 | def GetEdkLogger():\r | |
15 | import logging\r | |
16 | return logging.getLogger('edk')\r | |
17 | \r | |
18 | class EdkException(Exception):\r | |
19 | def __init__(self, message, fName=None, fNo=None):\r | |
20 | self._message = message\r | |
21 | ErrorMsg(message, fName, fNo)\r | |
22 | \r | |
23 | def GetMessage(self):\r | |
24 | return '[EDK Failure]: %s' %self._message\r | |
25 | \r | |
26 | def ErrorMsg(mess, fName=None, fNo=None):\r | |
27 | GetEdkLogger().error(NormalMessage('#ERR#', mess, fName, fNo))\r | |
28 | \r | |
29 | def LogMsg(mess, fName=None, fNo=None):\r | |
30 | GetEdkLogger().info(NormalMessage('@LOG@', mess, fName, fNo))\r | |
31 | \r | |
32 | def WarnMsg(mess, fName=None, fNo=None):\r | |
33 | GetEdkLogger().warning(NormalMessage('!WAR!', mess, fName, fNo))\r | |
34 | \r | |
35 | def NormalMessage(type, mess, fName=None, fNo=None):\r | |
36 | strMsg = type\r | |
37 | \r | |
4231a819 | 38 | if fName is not None:\r |
7ccc9c95 | 39 | strMsg += ' %s' % fName.replace('/', '\\')\r |
4231a819 | 40 | if fNo is not None:\r |
7ccc9c95 YZ |
41 | strMsg += '(%d):' % fNo\r |
42 | else:\r | |
43 | strMsg += ' :'\r | |
44 | \r | |
4231a819 | 45 | if fName is None and fNo is None:\r |
7ccc9c95 YZ |
46 | strMsg += ' '\r |
47 | strMsg += mess\r | |
48 | \r | |
49 | return strMsg\r | |
50 | \r | |
51 | \r | |
52 | \r |