ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wheleph <whel...@gmail.com>
Subject null system properties in buildStarted()
Date Sat, 05 Jul 2008 17:37:06 GMT

Hello everyone.
I use XmlLogger as a listener, but additionally I'd like to set custom log
level. Hence I created CustomXmlLogger (child of XmlLogger) and depending on
user property "XmlLogger.level" set the appropriate loglevel.
I've put this code into buildStarted() method, but this property and
standard "XmlLogger.file" are undefined.
In buildFinished() both properties are set.
I'd like to know why properties are not defined in buildStarted(). And how
to workaround this.

Source:
public class CustomXmlLogger extends XmlLogger {
	@Override
	public void buildStarted(BuildEvent event) {
		super.buildStarted(event);
		String fileStr = event.getProject().getProperty("XmlLogger.file");
		System.out.println("fileStr = " + fileStr);
		String levelStr = event.getProject().getProperty("XmlLogger.level");
		System.out.println("levelStr = " + levelStr);
		if (levelStr != null) {
			int level;
			if (levelStr.equalsIgnoreCase("ERR")) {
				level = Project.MSG_ERR;
			} else if (levelStr.equalsIgnoreCase("WARN")) {
				level = Project.MSG_WARN;
			} else if (levelStr.equalsIgnoreCase("INFO")) {
				level = Project.MSG_INFO;
			} else if (levelStr.equalsIgnoreCase("VERBOSE")) {
				level = Project.MSG_VERBOSE;
			} else {
				level = Project.MSG_DEBUG;
			}
			setMessageOutputLevel(level);
			System.out.println("level = " + level);
		}
	}
	
	@Override
	public void buildFinished(BuildEvent event) {
		super.buildFinished(event);
		String fileStr = event.getProject().getProperty("XmlLogger.file");
		System.out.println("fileStr = " + fileStr);
		String levelStr = event.getProject().getProperty("XmlLogger.level");
		System.out.println("levelStr = " + levelStr);
	}
}

Output:
D:\home\UMC\.garbage>ant -lib VCS.jar -listener
com.kvazarmicro.umc.vcs.utils.Cu
stomXmlLogger -DXmlLogger.file=build_test_log.xml  -DXmlLogger.level=ERR
Buildfile: build.xml
fileStr = null
levelStr = null

test:

tar1:
     [echo] Still alive

tar2:
     [echo] Still alive

BUILD SUCCESSFUL
Total time: 0 seconds
fileStr = build_test_log.xml
levelStr = ERR
-- 
View this message in context: http://www.nabble.com/null-system-properties-in-buildStarted%28%29-tp18294458p18294458.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message