source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/NoBannerLogger.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 2.7 KB
Line 
1/*
2 * Copyright 2000-2002,2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant;
19
20import org.apache.tools.ant.util.StringUtils;
21
22/**
23 * Extends DefaultLogger to strip out empty targets.
24 *
25 */
26public class NoBannerLogger extends DefaultLogger {
27
28 /**
29 * Name of the current target, if it should
30 * be displayed on the next message. This is
31 * set when a target starts building, and reset
32 * to <code>null</code> after the first message for
33 * the target is logged.
34 */
35 protected String targetName;
36 protected String targetAddress;
37
38 /** Sole constructor. */
39 public NoBannerLogger() {
40 }
41
42 /**
43 * Notes the name of the target so it can be logged
44 * if it generates any messages.
45 *
46 * @param event A BuildEvent containing target information.
47 * Must not be <code>null</code>.
48 */
49 public void targetStarted(BuildEvent event) {
50 targetName = event.getTarget().getName();
51 targetName = event.getTarget().getAddress();
52 }
53
54 /**
55 * Resets the current target name to <code>null</code>.
56 *
57 * @param event Ignored in this implementation.
58 */
59 public void targetFinished(BuildEvent event) {
60 targetName = null;
61 targetAddress = null;
62 }
63
64 /**
65 * Logs a message for a target if it is of an appropriate
66 * priority, also logging the name of the target if this
67 * is the first message which needs to be logged for the
68 * target.
69 *
70 * @param event A BuildEvent containing message information.
71 * Must not be <code>null</code>.
72 */
73 public void messageLogged(BuildEvent event) {
74
75 if (event.getPriority() > msgOutputLevel
76 || null == event.getMessage()
77 || "".equals(event.getMessage().trim())) {
78 return;
79 }
80
81 if (null != targetName) {
82 out.println(StringUtils.LINE_SEP + targetAddress + " " + targetName + ":");
83 targetName = null;
84 targetAddress = null;
85 }
86
87 super.messageLogged(event);
88 }
89}
Note: See TracBrowser for help on using the repository browser.