878ddf1f |
1 | /** @file\r |
2 | ActionMessage class.\r |
3 | \r |
4 | ActionMessage class take over all message for loging and waning. This class should\r |
5 | dispatch message into different class according to instance class type.\r |
6 | \r |
7 | Copyright (c) 2006, Intel Corporation\r |
8 | All rights reserved. This program and the accompanying materials\r |
9 | are licensed and made available under the terms and conditions of the BSD License\r |
10 | which accompanies this distribution. The full text of the license may be found at\r |
11 | http://opensource.org/licenses/bsd-license.php\r |
12 | \r |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
15 | \r |
16 | **/\r |
d14ebb43 |
17 | package org.tianocore.pcd.action;\r |
878ddf1f |
18 | \r |
19 | import org.apache.tools.ant.Task;\r |
878ddf1f |
20 | \r |
21 | /** ActionMessage class take over all message for loging and waning. This class \r |
22 | should dispatch message into different Action class according to instance \r |
23 | class type.\r |
24 | **/\r |
25 | public class ActionMessage {\r |
26 | ///\r |
27 | /// Macro definition for NULL messge level. \r |
28 | /// In this meessage level, all message will be hidden.\r |
29 | ///\r |
30 | public final static int NULL_MESSAGE_LEVEL = 0; \r |
31 | ///\r |
32 | /// Macro definition for Log messge level.\r |
33 | /// In this message level, Only log information will be shown.\r |
34 | ///\r |
35 | public final static int LOG_MESSAGE_LEVEL = 1;\r |
36 | ///\r |
37 | /// Macro definition for Warning message level. \r |
38 | /// In this message level, log and waning message will be shown.\r |
39 | ///\r |
40 | public final static int WARNING_MESSAGE_LEVEL = 2;\r |
41 | ///\r |
42 | /// Macro definition for Debug mesage level.\r |
43 | /// In this message level, log, warning, debug message will be shown.\r |
44 | ///\r |
45 | public final static int DEBUG_MESSAGE_LEVEL = 3;\r |
46 | ///\r |
47 | /// Macor definition for MAX message level.\r |
48 | /// In this message level, all message will be shown.\r |
49 | ///\r |
50 | public final static int MAX_MESSAGE_LEVEL = 4;\r |
51 | ///\r |
52 | /// Current message level. It will control all message output for PCD tool.\r |
53 | ///\r |
54 | public static int messageLevel = NULL_MESSAGE_LEVEL;\r |
55 | \r |
56 | /**\r |
57 | Log() function provide common log information functionality for all \r |
58 | PCD tool includes all function\r |
59 | \r |
60 | This function will dispatch message to special class such as BuildAction\r |
61 | Class, Entity Class etc.\r |
62 | \r |
63 | @param thisClass The class object who want log information.\r |
64 | @param logStr The string contains log information.\r |
65 | **/\r |
66 | public static void log(Object thisClass, String logStr) {\r |
67 | if(messageLevel < LOG_MESSAGE_LEVEL) {\r |
68 | return;\r |
69 | }\r |
70 | \r |
71 | if(thisClass instanceof Task) {\r |
72 | BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);\r |
878ddf1f |
73 | } else {\r |
74 | System.out.println("$$LOG$$:" + logStr);\r |
75 | }\r |
76 | }\r |
77 | \r |
78 | /**\r |
79 | Warning() function provide common warning information functionality for all \r |
80 | PCD tool.\r |
81 | \r |
82 | This function will dispatch message to special class such as BuildAction\r |
83 | Class, Entity Class etc.\r |
84 | \r |
85 | @param thisClass The class object who want warn information.\r |
86 | @param warningStr The string contains warning information.\r |
87 | **/ \r |
88 | public static void warning(Object thisClass, String warningStr) {\r |
89 | if(messageLevel < WARNING_MESSAGE_LEVEL) {\r |
90 | return;\r |
91 | }\r |
92 | \r |
93 | if(thisClass instanceof Task) {\r |
94 | BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);\r |
878ddf1f |
95 | } else {\r |
96 | System.out.println("**WARNING**:" + warningStr);\r |
97 | }\r |
98 | }\r |
99 | \r |
100 | /**\r |
101 | Debug() function provide common Debug information functionality for all \r |
102 | PCD tool.\r |
103 | \r |
104 | This function will dispatch message to special class such as BuildAction\r |
105 | Class, Entity Class etc.\r |
106 | \r |
107 | @param thisClass The class object who want Debug information.\r |
108 | @param debugStr The string contains Debug information.\r |
109 | **/ \r |
110 | public static void debug(Object thisClass, String debugStr) {\r |
111 | if(messageLevel < DEBUG_MESSAGE_LEVEL) {\r |
112 | return;\r |
113 | }\r |
114 | \r |
115 | if(thisClass instanceof Task) {\r |
116 | BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);\r |
878ddf1f |
117 | } else {\r |
118 | System.out.println("%%DEBUG%%:" + debugStr);\r |
119 | }\r |
120 | }\r |
121 | }\r |