588
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.helium.logger.ant.taskdefs;
|
|
18 |
|
628
|
19 |
import org.apache.log4j.Logger;
|
588
|
20 |
import org.apache.tools.ant.Project;
|
|
21 |
import org.apache.tools.ant.Task;
|
|
22 |
|
|
23 |
import com.nokia.helium.logger.ant.listener.AntLoggingHandler;
|
|
24 |
import com.nokia.helium.logger.ant.listener.StatusAndLogListener;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* This task is used to start the helium logging listener.
|
|
28 |
* @ant.task name="triggerlogger" category="Logging"
|
|
29 |
*/
|
|
30 |
public class TriggerLoggerTask extends Task {
|
|
31 |
|
|
32 |
private Logger log = Logger.getLogger(TriggerLoggerTask.class);
|
|
33 |
|
|
34 |
public void execute() {
|
|
35 |
log.debug("Registering Ant logging to StatusAndLogListener listener");
|
|
36 |
if (StatusAndLogListener.getStatusAndLogListener() == null) {
|
|
37 |
this.log("The StatusAndLogListener is not available.", Project.MSG_WARN);
|
|
38 |
return;
|
|
39 |
}
|
|
40 |
AntLoggingHandler antLoggingHandler = new AntLoggingHandler(getProject());
|
|
41 |
StatusAndLogListener.getStatusAndLogListener().register(antLoggingHandler);
|
|
42 |
if (antLoggingHandler != null ) {
|
|
43 |
if (!antLoggingHandler.getLoggingStarted()) {
|
|
44 |
log.debug("Starting Logging using 'AntLoggingHandler' first time.");
|
|
45 |
antLoggingHandler.setLoggingStarted(true);
|
|
46 |
} else {
|
|
47 |
log.debug("'AntLoggingHandler' is already started logging.");
|
|
48 |
}
|
|
49 |
} else {
|
|
50 |
log.debug("Could not find the AntLoggingHandler instance.");
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
}
|