/** * @file Common/logger.cpp * @brief iLogger interface implementation * @author Enar Vaikene * * Copyright (c) 2011 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #include "logger.h" #include "iregistry.h" #include "ienv.h" #include #ifdef Q_OS_WIN32 # include #endif #ifdef Q_OS_LINUX # include # include # include #endif //------------------------------------------------------------------- using namespace eVaf::Common; iLogger * iLogger::instance() { static Internal::Logger singleton; return &singleton; } //------------------------------------------------------------------- using namespace eVaf::Common::Internal; void defFatalMsgHandler(QString const & msg, QString const & source, QString const & where) { Q_UNUSED(source); fprintf(stderr, "FATAL ERROR: %s (occurred in %s)\n", qPrintable(msg), qPrintable(where)); #ifdef Q_OS_LINUX abort(); #else exit(1); #endif } //------------------------------------------------------------------- LoggerSource::LoggerSource() : QSharedData() , severity(iLogger::Fatal) , maxSize(100 * 1024) , maxCount(3) {} LoggerSource::LoggerSource(LoggerSource const & o) : QSharedData() , severity(o.severity) , maxSize(o.maxSize) , maxCount(o.maxCount) {} void LoggerSource::init(QString const & source, QString const & logDir, QString const & etcDir) { Q_UNUSED(etcDir); fileName = logDir + source + ".log"; } //-------------------------------------------------------------------