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