buildframework/helium/sf/java/legacy/src/com/nokia/ant/taskdefs/StopLogToConsoleTask.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185

/*
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


package com.nokia.ant.taskdefs;

import org.apache.tools.ant.Task;

import com.nokia.ant.HeliumLogger;

/**
 * This task is deprecated, please consider using the 
 * hlm:taskRecorder task from the logging framework.
 * 
 * This task will control the outputing of the Helium logger.
 * 
 * Example of usage, to stop logging to console:
 * <pre>
 * &lt;hlm:logtoconsole action="stop"/&gt;
 * </pre>
 *  
 * To resume logging to console:
 * <pre>
 * &lt;hlm:logtoconsole action="start"/&gt;
 * </pre> 
 * 
 * @ant.task name="logtoconsole" category="Logging"
 * @deprecated This task is deprecated, please consider using the 
 * hlm:taskRecorder task from the logging framework.
 */ 
@Deprecated
public class StopLogToConsoleTask extends Task 
{   
    private boolean stopLogToConsole;
    
    /**
     * Action to perform, stop/start logging.
     * @ant.not-required Default value is start.
     */
    public void setAction(String msg)
    {
        if ( msg.equalsIgnoreCase("stop") )
        {
            stopLogToConsole = true;
        }
        else
        {
            stopLogToConsole = false;
        }       
    }

    @Override
    public void execute()
    {
        super.execute();
        if (HeliumLogger.getStopLogToConsole() != stopLogToConsole)
        {
            if (stopLogToConsole) {
                log("Logging to console suspended.");
            }
            HeliumLogger.setStopLogToConsole(stopLogToConsole);   
            if (!stopLogToConsole) {
                log("Logging to console resumed.");
            }
        }       
    }   
}