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 |
|
|
18 |
|
|
19 |
package com.nokia.ant.taskdefs;
|
|
20 |
|
|
21 |
import org.apache.tools.ant.Task;
|
|
22 |
import com.nokia.ant.HeliumLogger;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* This task will control the outputing of the Helium logger.
|
|
26 |
*
|
|
27 |
* Example of usage, to stop logging to console:
|
|
28 |
* <pre>
|
|
29 |
* <hlm:logtoconsole action="stop"/>
|
|
30 |
* </pre>
|
|
31 |
*
|
|
32 |
* To resume logging to console:
|
|
33 |
* <pre>
|
|
34 |
* <hlm:logtoconsole action="start"/>
|
|
35 |
* </pre>
|
|
36 |
*
|
|
37 |
* @ant.task name="logtoconsole" category="Logging"
|
|
38 |
*/
|
|
39 |
public class StopLogToConsoleTask extends Task
|
|
40 |
{
|
|
41 |
private boolean stopLogToConsole;
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Action to perform, stop/start logging.
|
|
45 |
* @ant.not-required Default value is start.
|
|
46 |
*/
|
|
47 |
public void setAction(String msg)
|
|
48 |
{
|
|
49 |
if ( msg.equalsIgnoreCase("stop") )
|
|
50 |
{
|
|
51 |
stopLogToConsole = true;
|
|
52 |
}
|
|
53 |
else
|
|
54 |
{
|
|
55 |
stopLogToConsole = false;
|
|
56 |
}
|
|
57 |
}
|
|
58 |
|
|
59 |
@Override
|
|
60 |
public void execute()
|
|
61 |
{
|
|
62 |
super.execute();
|
|
63 |
if (HeliumLogger.getStopLogToConsole() != stopLogToConsole)
|
|
64 |
{
|
|
65 |
if (stopLogToConsole)
|
|
66 |
log("Logging to console suspended.");
|
|
67 |
HeliumLogger.setStopLogToConsole(stopLogToConsole);
|
|
68 |
if (!stopLogToConsole)
|
|
69 |
log("Logging to console resumed.");
|
|
70 |
}
|
|
71 |
}
|
|
72 |
}
|