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