javatools/javacontrolpanel/controlpanel/src.s60/logredirector.cpp
branchRCL_3
changeset 60 6c158198356e
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
       
     1 /*
       
     2 * Copyright (c) 2010 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 "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 #include <fcntl.h>
       
    19 #include <sys/types.h>
       
    20 #include <sys/stat.h>
       
    21 #include <unistd.h>
       
    22 #include "logredirector.h"
       
    23 
       
    24 LogRedirector::LogRedirector() : mFd(-1)
       
    25 {
       
    26     iJavaDiagnostic.reset(JavaDiagnostic::createInstance());
       
    27 }
       
    28 
       
    29 LogRedirector::~LogRedirector()
       
    30 {
       
    31 }
       
    32 
       
    33 void LogRedirector::start()
       
    34 {
       
    35     iJavaDiagnostic->setDiagnosticListener(*this);
       
    36     mFd = open("c:\\data\\javaredirect.log", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
       
    37 }
       
    38 
       
    39 void LogRedirector::stop()
       
    40 {
       
    41     iJavaDiagnostic->removeDiagnosticListener();
       
    42     close(mFd);
       
    43     mFd = -1;
       
    44 }
       
    45 
       
    46 void LogRedirector::systemOut(const TDesC8& aData)
       
    47 {
       
    48     write(aData);
       
    49 }
       
    50 
       
    51 void LogRedirector::systemErr(const TDesC8& aData)
       
    52 {
       
    53     write(aData);
       
    54 }
       
    55 
       
    56 void LogRedirector::log(const TDesC8& aData)
       
    57 {
       
    58     write(aData);
       
    59 }
       
    60 
       
    61 void LogRedirector::write(const TDesC8& aData)
       
    62 {
       
    63     if (mFd > 0)
       
    64     {
       
    65         ::write(mFd, (const char*)aData.Ptr(), aData.Size());
       
    66     }
       
    67 };
       
    68