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