]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java
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
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.
19 package org
.tianocore
.build
.global
;
22 import java
.util
.List
;
23 import java
.util
.Vector
;
25 import org
.apache
.tools
.ant
.Project
;
26 import org
.apache
.tools
.ant
.Task
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
29 import org
.tianocore
.common
.logger
.LogMethod
;
31 public class GenBuildLogger
implements LogMethod
{
32 private Project project
= null;
35 /// flag to present whether cache all msg or not
36 /// true means not to cache.
38 private boolean flag
= true;
40 private List
<String
> v
= null;
42 public GenBuildLogger (Project project
) {
43 this.project
= project
;
46 public GenBuildLogger (Project project
, boolean flag
) {
47 this.project
= project
;
51 // Only flag is false, v will be initialized and used.
54 v
= new Vector
<String
>(2048);
59 Rules: flag = true: means no cache Action: Print it to console
61 flag = false: mean cache all msg exception some special Action: loglevel
62 is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and
63 cache the msg others -- No print and cache the msg
65 public synchronized void putMessage(Object msgSource
, int msgLevel
,
67 if (this.project
== null) {
72 // If msgLevel is always print, then print it
75 case EdkLog
.EDK_ALWAYS
:
76 log(msgSource
, msg
, Project
.MSG_INFO
);
78 case EdkLog
.EDK_ERROR
:
80 log(msgSource
, msg
, Project
.MSG_ERR
);
82 log(msgSource
, msg
, Project
.MSG_ERR
);
86 case EdkLog
.EDK_WARNING
:
88 log(msgSource
, msg
, Project
.MSG_WARN
);
95 log(msgSource
, msg
, Project
.MSG_INFO
);
100 case EdkLog
.EDK_VERBOSE
:
102 log(msgSource
, msg
, Project
.MSG_VERBOSE
);
107 case EdkLog
.EDK_DEBUG
:
109 log(msgSource
, msg
, Project
.MSG_DEBUG
);
117 public void flushToFile(File file
) {
119 // Sort msg and store to the file (TBD)
124 private void log(Object msgSource
, String msg
, int level
) {
125 if (msgSource
instanceof Task
) {
126 this.project
.log((Task
)msgSource
, msg
, level
);
127 } else if (msgSource
instanceof String
){
130 // Pad 12 space to keep message
132 msg
= msg
.replaceAll("\n", "\n ");
133 this.project
.log(String
.format("%12s", "[" + msgSource
+ "] ") + msg
, level
);
135 this.project
.log(msg
, level
);