add log4cplus
This commit is contained in:
122
libs/log4cplus/src/loglog.cxx
Normal file
122
libs/log4cplus/src/loglog.cxx
Normal file
@ -0,0 +1,122 @@
|
||||
// Module: Log4CPLUS
|
||||
// File: loglog.cxx
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2009 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/helpers/loglog.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace log4cplus;
|
||||
using namespace log4cplus::helpers;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static tchar const PREFIX[] = LOG4CPLUS_TEXT("log4cplus: ");
|
||||
static tchar const WARN_PREFIX[] = LOG4CPLUS_TEXT("log4cplus:WARN ");
|
||||
static tchar const ERR_PREFIX[] = LOG4CPLUS_TEXT("log4cplus:ERROR ");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// static methods
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SharedObjectPtr<LogLog>
|
||||
LogLog::getLogLog()
|
||||
{
|
||||
static SharedObjectPtr<LogLog> singleton(new LogLog());
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// log4cplus::helpers::LogLog ctor and dtor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LogLog::LogLog()
|
||||
: mutex(LOG4CPLUS_MUTEX_CREATE),
|
||||
debugEnabled(false),
|
||||
quietMode(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LogLog::~LogLog()
|
||||
{
|
||||
LOG4CPLUS_MUTEX_FREE( mutex );
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// log4cplus::helpers::LogLog public methods
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
LogLog::setInternalDebugging(bool enabled)
|
||||
{
|
||||
debugEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LogLog::setQuietMode(bool quietModeVal)
|
||||
{
|
||||
quietMode = quietModeVal;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LogLog::debug(const log4cplus::tstring& msg)
|
||||
{
|
||||
LOG4CPLUS_BEGIN_SYNCHRONIZE_ON_MUTEX( mutex )
|
||||
if(debugEnabled && !quietMode) {
|
||||
tcout << PREFIX << msg << endl;
|
||||
}
|
||||
LOG4CPLUS_END_SYNCHRONIZE_ON_MUTEX;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LogLog::warn(const log4cplus::tstring& msg)
|
||||
{
|
||||
LOG4CPLUS_BEGIN_SYNCHRONIZE_ON_MUTEX( mutex )
|
||||
if(quietMode) return;
|
||||
|
||||
tcerr << WARN_PREFIX << msg << endl;
|
||||
LOG4CPLUS_END_SYNCHRONIZE_ON_MUTEX;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LogLog::error(const log4cplus::tstring& msg)
|
||||
{
|
||||
LOG4CPLUS_BEGIN_SYNCHRONIZE_ON_MUTEX( mutex )
|
||||
if(quietMode) return;
|
||||
|
||||
tcerr << ERR_PREFIX << msg << endl;
|
||||
LOG4CPLUS_END_SYNCHRONIZE_ON_MUTEX;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user