buildframework/helium/sf/java/legacy/src/com/nokia/ant/taskdefs/StopLogToConsoleTask.java
author wbernard
Wed, 16 Jun 2010 16:51:40 +0300
changeset 588 c7c26511138f
child 628 7c4a911dc066
permissions -rw-r--r--
helium-10.0.0-bc45d50958fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     1
/*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     3
* All rights reserved.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     8
*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
     9
* Initial Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    11
*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    12
* Contributors:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    13
*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    14
* Description: 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    15
*
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    16
*/
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    17
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    18
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    19
package com.nokia.ant.taskdefs;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    20
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    21
import org.apache.tools.ant.Task;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    22
import com.nokia.ant.HeliumLogger;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    23
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    24
/**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    25
 * This task will control the outputing of the Helium logger.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    26
 * 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    27
 * Example of usage, to stop logging to console:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    28
 * <pre>
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    29
 * &lt;hlm:logtoconsole action="stop"/&gt;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    30
 * </pre>
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    31
 *  
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    32
 * To resume logging to console:
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    33
 * <pre>
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    34
 * &lt;hlm:logtoconsole action="start"/&gt;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    35
 * </pre> 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    36
 * 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    37
 * @ant.task name="logtoconsole" category="Logging"
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    38
 */ 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    39
public class StopLogToConsoleTask extends Task 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    40
{   
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    41
    private boolean stopLogToConsole;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    42
    
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    43
    /**
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    44
     * Action to perform, stop/start logging.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    45
     * @ant.not-required Default value is start.
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    46
     */
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    47
    public void setAction(String msg)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    48
    {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    49
        if ( msg.equalsIgnoreCase("stop") )
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    50
        {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    51
            stopLogToConsole = true;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    52
        }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    53
        else
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    54
        {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    55
            stopLogToConsole = false;
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    56
        }       
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    57
    }
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    58
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    59
    @Override
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    60
    public void execute()
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    61
    {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    62
        super.execute();
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    63
        if (HeliumLogger.getStopLogToConsole() != stopLogToConsole)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    64
        {
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    65
            if (stopLogToConsole)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    66
                log("Logging to console suspended.");             
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    67
            HeliumLogger.setStopLogToConsole(stopLogToConsole);   
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    68
            if (!stopLogToConsole)
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    69
                log("Logging to console resumed."); 
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    70
        }       
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    71
    }   
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents:
diff changeset
    72
}