]>
Commit | Line | Data |
---|---|---|
1 | /*++\r | |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | GenBuildLogger.java\r | |
14 | \r | |
15 | Abstract:\r | |
16 | \r | |
17 | --*/\r | |
18 | \r | |
19 | package org.tianocore.build.global;\r | |
20 | \r | |
21 | import java.io.File;\r | |
22 | import java.util.List;\r | |
23 | import java.util.Vector;\r | |
24 | \r | |
25 | import org.apache.tools.ant.Project;\r | |
26 | \r | |
27 | import org.tianocore.common.logger.EdkLog;\r | |
28 | import org.tianocore.common.logger.LogMethod;\r | |
29 | \r | |
30 | public class GenBuildLogger implements LogMethod {\r | |
31 | private Project project = null;\r | |
32 | \r | |
33 | ///\r | |
34 | /// flag to present whether cache all msg or not\r | |
35 | /// true means not to cache.\r | |
36 | ///\r | |
37 | private boolean flag = true;\r | |
38 | \r | |
39 | private List<String> v = null;\r | |
40 | \r | |
41 | public GenBuildLogger (Project project) {\r | |
42 | this.project = project;\r | |
43 | }\r | |
44 | \r | |
45 | public GenBuildLogger (Project project, boolean flag) {\r | |
46 | this.project = project;\r | |
47 | this.flag = flag;\r | |
48 | \r | |
49 | //\r | |
50 | // Only flag is false, v will be initialized and used.\r | |
51 | //\r | |
52 | if (!flag) {\r | |
53 | v = new Vector<String>(2048);\r | |
54 | }\r | |
55 | }\r | |
56 | \r | |
57 | /**\r | |
58 | Rules: flag = true: means no cache Action: Print it to console\r | |
59 | \r | |
60 | flag = false: mean cache all msg exception some special Action: loglevel\r | |
61 | is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and\r | |
62 | cache the msg others -- No print and cache the msg\r | |
63 | **/\r | |
64 | public synchronized void putMessage(Object msgSource, int msgLevel,\r | |
65 | String msg) {\r | |
66 | if (this.project == null) {\r | |
67 | return;\r | |
68 | }\r | |
69 | \r | |
70 | //\r | |
71 | // If msgLevel is always print, then print it\r | |
72 | //\r | |
73 | switch (msgLevel) {\r | |
74 | case EdkLog.EDK_ALWAYS:\r | |
75 | this.project.log(msg, Project.MSG_INFO);\r | |
76 | break;\r | |
77 | case EdkLog.EDK_ERROR:\r | |
78 | if (flag) {\r | |
79 | this.project.log(msg, Project.MSG_ERR);\r | |
80 | } else {\r | |
81 | this.project.log(msg, Project.MSG_ERR);\r | |
82 | v.add(msg);\r | |
83 | }\r | |
84 | break;\r | |
85 | case EdkLog.EDK_WARNING:\r | |
86 | if (flag) {\r | |
87 | this.project.log(msg, Project.MSG_WARN);\r | |
88 | } else {\r | |
89 | v.add(msg);\r | |
90 | }\r | |
91 | break;\r | |
92 | case EdkLog.EDK_INFO:\r | |
93 | if (flag) {\r | |
94 | this.project.log(msg, Project.MSG_INFO);\r | |
95 | } else {\r | |
96 | v.add(msg);\r | |
97 | }\r | |
98 | break;\r | |
99 | case EdkLog.EDK_VERBOSE:\r | |
100 | if (flag) {\r | |
101 | this.project.log(msg, Project.MSG_VERBOSE);\r | |
102 | } else {\r | |
103 | v.add(msg);\r | |
104 | }\r | |
105 | break;\r | |
106 | case EdkLog.EDK_DEBUG:\r | |
107 | if (flag) {\r | |
108 | this.project.log(msg, Project.MSG_DEBUG);\r | |
109 | } else {\r | |
110 | v.add(msg);\r | |
111 | }\r | |
112 | break;\r | |
113 | }\r | |
114 | }\r | |
115 | \r | |
116 | public void flushToFile(File file) {\r | |
117 | //\r | |
118 | // Sort msg and store to the file (TBD)\r | |
119 | //\r | |
120 | \r | |
121 | }\r | |
122 | } |