diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d569217 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.o +autom4te* +config.* +.deps +.dirstamp +ltmain.sh +m4/ +Makefile +libtool +*.xml +stamp-h1 +*.nsi +monitord/monitord diff --git a/Makefile.am b/Makefile.am index 63d3c0d..217f2ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,12 @@ endif endif +# log4cxx einbinden +if LOG4CXX +monitord_monitord_LDFLAGS += @LOG4CXX_LIBS@ +monitord_monitord_CPPFLAGS += -I@LOG4CXX_INCLUDE@ +endif + # LUA Headers und Libs einbinden monitord_monitord_CPPFLAGS += @LUA_INCLUDE@ monitord_monitord_LDFLAGS += @LUA_LIB@ diff --git a/configure.ac b/configure.ac index 64db5e0..f57b518 100644 --- a/configure.ac +++ b/configure.ac @@ -58,7 +58,28 @@ fi AM_CONDITIONAL(ALSA, test x$HAVE_ALSA = xyes) +AC_ARG_WITH([log4cxx], + [AC_HELP_STRING([--with-log4cxx], + [enable log4cxx support (default is no)])], + [ + (use_log4cxx=$withval) + HAVE_LOG4CXX=yes + AC_DEFINE([HAVE_LOG4CXX], [1], [defines that you have log4cxx]) + ], + [use_log4cxx=no]) +AM_CONDITIONAL(LOG4CXX, test x$HAVE_LOG4CXX = xyes) + +AC_ARG_WITH([log4cxx-includes], + AC_HELP_STRING([--with-log4cxx-includes=PFX], [Prefix where log4cxx header files are]), + [gccLog4cxxIncludes="$withval" + AC_SUBST(LOG4CXX_INCLUDE, "$gccLog4cxxIncludes")],) + +AC_ARG_WITH([log4cxx-libraries], + AC_HELP_STRING([--with-log4cxx-libraries=PFX], [Prefix where where libraries for log4cxx are. In the most environments, this must be set]), + [gccLog4cxxLibraries="$withval" + AC_SUBST(LOG4CXX_LIBS, "$gccLog4cxxLibraries")],) + if test x$WINDOWS != xtrue; then # Linux OS: # First check for libm - otherwise libmp3lame will always fail diff --git a/monitord/Monitor.cpp b/monitord/Monitor.cpp index 7b2c819..ee50231 100644 --- a/monitord/Monitor.cpp +++ b/monitord/Monitor.cpp @@ -29,7 +29,10 @@ #include "lua.hpp" using namespace std ; - +#ifdef HAVE_LOG4CXX +using namespace log4cxx; +using namespace log4cxx::helpers; +#endif // HAVE_LOG4CXX void Monitor::CreateSocketServer(MonitorConfiguration *config) { static SocketServer socketServer(config,0) ; @@ -48,10 +51,10 @@ void Monitor::Initialize (int argc, char *argv[]) { - m_bWantStop=false; - if ( memLockCreate( 12345, & s) < 0) { - ThrowMonitorException("memLockCreate failed") ; - } + m_bWantStop=false; + if ( memLockCreate( 12345, & s) < 0) { + ThrowMonitorException("memLockCreate failed") ; + } m_MonitorConfig.ParseCommandline(argc,argv) ; m_MonitorConfig.ReadConfiguration(m_MonitorConfig.m_ConfigFile) ; @@ -60,17 +63,37 @@ void initFileLogging(MonitorConfiguration *config) { + bool bConfigureReportingLevel = true; - if (!(config->m_sLogfile=="screen")) + if (!(config->m_sLogfile=="screen") && !(config->m_sLogfile=="log4cxx")) { FILE* pFile = fopen(config->m_sLogfile.c_str(), "a"); Output2FILE::Stream() = pFile; - FILE_LOG(logINFO) << "monitord restarted - logging with loglevel " << config->m_sLoglevel; - } else { - FILE_LOG(logINFO) << "Logging with loglevel " << config->m_sLoglevel; + LOG_INFO("monitord restarted - logging with loglevel " << config->m_sLoglevel) + } + else if (config->m_sLogfile=="log4cxx") { + #ifdef HAVE_LOG4CXX + cout << "using log4cxx for further logging..." << endl; + + if (config->m_sLogConfigurationFile=="") { + BasicConfigurator::configure(); + } + else { + cout << "using log4cxx configuration file '" << config->m_sLogConfigurationFile << "'" << endl; + PropertyConfigurator::configure(config->m_sLogConfigurationFile); + } + bConfigureReportingLevel = false; + #else + LOG_ERROR("log4cxx can not be used. monitord is not compiled --with-log4cxx") + #endif + } + else { + LOG_INFO("Logging with loglevel " << config->m_sLoglevel) } - FILELog::ReportingLevel() = FILELog::FromString(config->m_sLoglevel); + if (bConfigureReportingLevel) { + FILELog::ReportingLevel() = FILELog::FromString(config->m_sLoglevel); + } } int main(int argc, char** argv) @@ -89,20 +112,20 @@ try { if (m_monitor.m_MonitorConfig.m_service_uninstall == true) { - FILE_LOG(logINFO) << PACKAGE_NAME << " wird als Dienst entfernt."; + LOG_INFO(PACKAGE_NAME << " wird als Dienst entfernt.") /* uninstall service from service control daemon */ MonitorService *m_MonitorService = new MonitorService(&m_monitor); m_MonitorService->UnInstallService(); delete m_MonitorService; } else if (m_monitor.m_MonitorConfig.m_service_install == true) { - FILE_LOG(logINFO) << PACKAGE_NAME << " wird als Dienst eingerichtet."; + LOG_INFO(PACKAGE_NAME << " wird als Dienst eingerichtet.") /* install service in service control daemon */ MonitorService *m_MonitorService = new MonitorService(&m_monitor); m_MonitorService->InstallService(); delete m_MonitorService ; } else { if (m_monitor.m_MonitorConfig.m_service_run == true) { - FILE_LOG(logINFO) << PACKAGE_NAME << " startet als Dienst."; + LOG_INFO(PACKAGE_NAME << " startet als Dienst.") /* running monitor as windows service application */ MonitorService *m_MonitorService = new MonitorService(&m_monitor); m_MonitorService->Run (); @@ -110,10 +133,10 @@ } else { #endif /* running monitor as command line application */ - FILE_LOG(logINFO) << PACKAGE_STRING << " READY" ; + LOG_INFO(PACKAGE_STRING << " READY" ) cout << PACKAGE_STRING << " running...\r\n"; - if (!(m_monitor.m_MonitorConfig.m_sLogfile == "screen")) { - cout << "Logging in Logfiles, keine weiteren Ausgaben hier."; + if (!(m_monitor.m_MonitorConfig.m_sLogfile == "screen") && !(m_monitor.m_MonitorConfig.m_sLogfile == "log4cxx")) { + cout << "Logging in Logfiles, keine weiteren Ausgaben hier." << endl; } m_monitor.MainLoop (); #ifdef WIN32 @@ -123,13 +146,13 @@ { // FIXME: Dienste koennen nicht auf die Console schreiben, da siehe // unsichtbar im Hintergrund laufen - FILE_LOG(logERROR) << err.what() ; + LOG_ERROR(err.what() ) } #endif } catch (MonitorException(err)) { - FILE_LOG(logERROR) << err.what() ; + LOG_ERROR(err.what() ) } } @@ -144,18 +167,18 @@ static SocketServer socketServer(&m_MonitorConfig,m_MonitorConfig.m_socketFilterFileName ,0) ; socketServer.Start() ; - FILE_LOG(logINFO) << "monitord socketserver started" ; + LOG_INFO("monitord socketserver started" ) static SocketServer fms32ProServer(&m_MonitorConfig,m_MonitorConfig.m_socketFilterFileName ,1000) ; fms32ProServer.m_ServerModus=SocketThread::fms32pro ; fms32ProServer.Start() ; - FILE_LOG(logINFO) << "fms32pro socketserver started" ; + LOG_INFO("fms32pro socketserver started" ) static SocketServer crusaderServer(&m_MonitorConfig,m_MonitorConfig.m_socketFilterFileName ,2000) ; crusaderServer.m_ServerModus=SocketThread::crusader ; crusaderServer.Start() ; - FILE_LOG(logINFO) << "crusader socketserver started" ; + LOG_INFO("crusader socketserver started" ) /*******************************************************/ @@ -164,7 +187,7 @@ //GetPluginsManager().loadPlugin("plugins/.libs/libmplugin_mysql-0.dll",NULL); GetPluginsManager().loadScriptFilter(m_MonitorConfig.m_pluginFilterFileName) ; GetPluginsManager().loadPluginsFromConfigNode(&m_MonitorConfig.m_configDataPlugins); - FILE_LOG(logDEBUG) << "PluginManager started" ; + LOG_DEBUG("PluginManager started" ) #endif /*********************************************************/ @@ -190,20 +213,20 @@ // Wie man sieht: hier gibt es im Moment nichts zu tun :- } - FILE_LOG(logINFO) << PACKAGE_NAME << " shutting down..." ; + LOG_INFO(PACKAGE_NAME << " shutting down..." ) StopSndCard() ; - FILE_LOG(logINFO) << "stopping socketserver monitord"; + LOG_INFO("stopping socketserver monitord") socketServer.m_bWantStop=true ; - FILE_LOG(logINFO) << "stopping socketserver FMS32"; + LOG_INFO("stopping socketserver FMS32") fms32ProServer.m_bWantStop=true ; - FILE_LOG(logINFO) << "stopping socketserver Crusader"; + LOG_INFO("stopping socketserver Crusader") crusaderServer.m_bWantStop=true ; usleep(1000) ; m_SignalStopped->SetSignal() ; usleep(500) ; - FILE_LOG(logINFO) << "all done. " << PACKAGE_NAME << " exiting"; + LOG_INFO("all done. " << PACKAGE_NAME << " exiting") } void Monitor::InitSndCard() @@ -214,7 +237,7 @@ if (m_MonitorConfig.m_sndConfig[cardnum].iAktiv==1) { m_sndIn[cardnum] = new CSndPipe(); - FILE_LOG(logINFO) << "starting soundcard #" << cardnum ; + LOG_INFO("starting soundcard #" << cardnum) m_sndIn[cardnum]->initDecoderModules(cardnum,&m_MonitorConfig) ; m_sndIn[cardnum]->m_SoundIn.setDevice(m_MonitorConfig.m_sndConfig[cardnum].sDevice, 22050) ; @@ -222,7 +245,7 @@ m_sndIn[cardnum]->loadPlugins(&m_MonitorConfig, m_MonitorConfig.m_sndConfig[cardnum].configChannel[0],m_MonitorConfig.m_sndConfig[cardnum].configChannel[1]) ; #endif m_sndIn[cardnum]->m_SoundIn.Start() ; - FILE_LOG(logINFO) << "Soundcard #" << cardnum << " started - complete" ; + LOG_INFO("Soundcard #" << cardnum << " started - complete" ) } } } @@ -235,9 +258,9 @@ { if (m_MonitorConfig.m_sndConfig[cardnum].iAktiv==1) { - FILE_LOG(logINFO) << "stopping soundcard# " << cardnum ; + LOG_INFO("stopping soundcard# " << cardnum ) m_sndIn[cardnum]->m_SoundIn.Stop() ; - FILE_LOG(logINFO) << "soundcard #" << cardnum<< " halted." ; + LOG_INFO("soundcard #" << cardnum<< " halted." ) delete m_sndIn[cardnum]; } } diff --git a/monitord/MonitorConfiguration.cpp b/monitord/MonitorConfiguration.cpp index e06780f..13cbc52 100644 --- a/monitord/MonitorConfiguration.cpp +++ b/monitord/MonitorConfiguration.cpp @@ -255,7 +255,7 @@ m_sMonitordName = getNodeText(config,"name","default") ; m_sLogfile = getNodeText(config,"logfile","screen") ; m_sLoglevel = getNodeText(config,"loglevel","INFO") ; - + m_sLogConfigurationFile = getNodeText(config, "log4cxxConfig", ""); m_socketFilterFileName=getNodeText(config,"SocketFilterScript","") ; m_pluginFilterFileName=getNodeText(config,"PluginFilterScript","") ; @@ -293,10 +293,6 @@ // Datenplugins m_configDataPlugins = config.getChildNode("dataplugins") ; - /*if (m_configDataPlugins.isEmpty()==false) - { - FILE_LOG(logINFO) << "dataplugins found !" ; - }*/ return true; } diff --git a/monitord/MonitorConfiguration.h b/monitord/MonitorConfiguration.h index 0b9f7eb..b25df1a 100644 --- a/monitord/MonitorConfiguration.h +++ b/monitord/MonitorConfiguration.h @@ -52,6 +52,7 @@ std::string m_sMonitordName ; std::string m_sLogfile ; std::string m_sLoglevel ; + std::string m_sLogConfigurationFile ; bool ReadConfiguration(std::string filename) ; bool ResetConfiguration() ; bool IsValidLogin(std::string loginname, std::string password, std::string host="") ; diff --git a/monitord/MonitorLogging.h b/monitord/MonitorLogging.h index 7d56531..502ee5c 100644 --- a/monitord/MonitorLogging.h +++ b/monitord/MonitorLogging.h @@ -10,7 +10,7 @@ #include #include #include "convert.h" - +#include "config.h" inline std::string NowTime(); @@ -133,10 +133,27 @@ #define FILELOG_MAX_LEVEL logDEBUG4 #endif +#ifdef HAVE_LOG4CXX +#include "log4cxx/logger.h" +#include "log4cxx/basicconfigurator.h" +#include "log4cxx/propertyconfigurator.h" +#include "log4cxx/helpers/exception.h" + +#define LOG_INSTANCE log4cxx::Logger::getLogger("monitord") +#define LOG_INFO(stream) LOG4CXX_INFO(LOG_INSTANCE, stream) +#define LOG_WARNING(stream) LOG4CXX_WARN(LOG_INSTANCE, stream) +#define LOG_DEBUG(stream) LOG4CXX_DEBUG(LOG_INSTANCE, stream) +#define LOG_ERROR(stream) LOG4CXX_ERROR(LOG_INSTANCE, stream) +#else // LOG4CXX #define FILE_LOG(level) \ - if (level > FILELOG_MAX_LEVEL) ;\ - else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \ - else FILELog().Get(level) << std::string(__FILE__) << "(" << convertIntToString(__LINE__) << ") " + if (level > FILELOG_MAX_LEVEL) ;\ + else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \ + else FILELog().Get(level) << std::string(__FILE__) << "(" << convertIntToString(__LINE__) << ") " +#define LOG_INFO(stream) FILE_LOG(logINFO) << stream; +#define LOG_WARNING(stream) FILE_LOG(logWARN) << stream; +#define LOG_DEBUG(stream) FILE_LOG(logDEBUG) << stream; +#define LOG_ERROR(stream) FILE_LOG(logERROR) << stream; +#endif // !LOG4CX #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) diff --git a/monitord/MonitorModuleFMS.cpp b/monitord/MonitorModuleFMS.cpp index f273483..048f63d 100644 --- a/monitord/MonitorModuleFMS.cpp +++ b/monitord/MonitorModuleFMS.cpp @@ -97,16 +97,16 @@ { float f; int i; - FILE_LOG(logDEBUG) << "FMS Parameter" ; - FILE_LOG(logDEBUG) << "sample : " << sampleRate ; - FILE_LOG(logDEBUG) << "syncbits: " << vorlaufbits ; - FILE_LOG(logDEBUG) << "crc : " << crccheck ; - FILE_LOG(logDEBUG) << "level : " << signallevel ; - FILE_LOG(logDEBUG) << "Algo : " << algorithm ; - FILE_LOG(logDEBUG) << "ignW : " << ignore_Wiederholung ; - FILE_LOG(logDEBUG) << "ignQ : " << ignore_Quittung ; - FILE_LOG(logDEBUG) << "ErrC : " << error_correction ; - FILE_LOG(logDEBUG) << "force : " << force_preambel ; + LOG_DEBUG( "FMS Parameter") + LOG_DEBUG( "sample : " << sampleRate) + LOG_DEBUG( "syncbits: " << vorlaufbits) + LOG_DEBUG( "crc : " << crccheck) + LOG_DEBUG( "level : " << signallevel) + LOG_DEBUG( "Algo : " << algorithm) + LOG_DEBUG( "ignW : " << ignore_Wiederholung) + LOG_DEBUG( "ignQ : " << ignore_Quittung) + LOG_DEBUG( "ErrC : " << error_correction) + LOG_DEBUG( "force : " << force_preambel) m_bErrorCorrection=error_correction ; m_iAlgorithmus=algorithm ; @@ -774,7 +774,7 @@ pRes->set("kfz",kfzString) ; pRes->set("textuebertragung",input) ; - FILE_LOG(logDEBUG) << (*pRes) << "-----" ; + pRes->Dump(); GlobalDispatcher->addResult(pRes) ; } ; } diff --git a/monitord/MonitorModulePocsag.cpp b/monitord/MonitorModulePocsag.cpp index 81efc14..16f8c5e 100644 --- a/monitord/MonitorModulePocsag.cpp +++ b/monitord/MonitorModulePocsag.cpp @@ -162,7 +162,7 @@ rx->rx_sync = 2 ; // war: 10 -- vielleicht auch 4/5/6 ? rx->rx_bit = rx->rx_word = 0; rx->func = -1; - FILE_LOG(logDEBUG)<< "Sync gefunden\n" ; + LOG_DEBUG("Sync gefunden") //TRACE0("Sync gefunden\n") ; m_iPreambelLen =0 ; m_bRXmode=true ; @@ -399,8 +399,7 @@ pRes->set("ric",Adresse) ; pRes->set("text",message) ; - FILE_LOG(logDEBUG) << "Debug(POCSAG):" << endl << (*pRes) ; - + pRes->Dump(); GlobalDispatcher->addResult(pRes) ; diff --git a/monitord/MonitorModulePocsag512.cpp b/monitord/MonitorModulePocsag512.cpp index b6bb6f0..711cc65 100644 --- a/monitord/MonitorModulePocsag512.cpp +++ b/monitord/MonitorModulePocsag512.cpp @@ -42,13 +42,7 @@ int minpreambel=getNodeInt(*pConfig,"minpreambel",300) ; int maxerrors=getNodeInt(*pConfig,"maxerrors",10) ; int algorithmus=getNodeInt(*pConfig,"algorithm",1) ; - FILE_LOG(logINFO) << "(1) sample - crc - ecc - minpreambel - maxerrors - algo:" - << sampleRate << " - " - << crccheck << " - " - << errorcorrection << " - " - << minpreambel << " - " - << maxerrors << " - " - << algorithmus ; + LOG_INFO("(1) sample - crc - ecc - minpreambel - maxerrors - algo :" << sampleRate << " - " << crccheck << " - " << errorcorrection << " - " << minpreambel << " - " << maxerrors << " - " << algorithmus) MonitorModulePocsag512(sampleRate,1,0) ; /* @@ -63,27 +57,21 @@ MonitorModulePocsag512::MonitorModulePocsag512(int sampleRate, bool crccheck, bool errorcorrection, int minpreambel, int maxerrors, int algorithmus) { - FILE_LOG(logINFO) << "(2) sample - crc - ecc - minpreambel - maxerrors - algo:" - << sampleRate << " - " - << crccheck << " - " - << errorcorrection << " - " - << minpreambel << " - " - << maxerrors << " - " - << algorithmus ; + LOG_INFO("(2) sample - crc - ecc - minpreambel - maxerrors - algo:" << sampleRate << " - " << crccheck << " - " << errorcorrection << " - " << minpreambel << " - " << maxerrors << " - " << algorithmus) m_bErrorCorrection=errorcorrection ; MAX_RX_ERRORS=maxerrors ; PREAMBEL_MINLEN=minpreambel ; m_iAlgorithmus=algorithmus ; - FILE_LOG(logINFO) << "Algorithmus:" << m_iAlgorithmus ; + LOG_INFO("Algorithmus:" << m_iAlgorithmus) FREQ_SAMP=sampleRate ; SPHASEINC=(0x10000u * BAUD * SUBSAMP) / FREQ_SAMP ; SPHASEINC_BASE=(0x10000u * BAUD * SUBSAMP) / FREQ_SAMP ; - FILE_LOG(logINFO) << "SPHASE_INC is:" << SPHASEINC_BASE ; + LOG_INFO("SPHASE_INC is:" << SPHASEINC_BASE) m_lpszName="POC 512" ; m_fPLLFaktor=PLLFaktor ; // max. Prozent-�nderungen Frq.-�nderung am PLL @@ -245,7 +233,6 @@ if (sphase>=0x10000u) { - // FILE_LOG(logINFO) << "sphase:" << sphase << " -> " << (sphase & (0xffff)) ; sphase = sphase & 0xffffu ; didBit = false ; } diff --git a/monitord/MonitorModuleZVEI.cpp b/monitord/MonitorModuleZVEI.cpp index 2a33cac..a92c9ea 100644 --- a/monitord/MonitorModuleZVEI.cpp +++ b/monitord/MonitorModuleZVEI.cpp @@ -697,8 +697,8 @@ pRes->set("zvei",Adresse) ; pRes->set("weckton",alarmTypString) ; pRes->set("text",Text) ; - - FILE_LOG(logDEBUG) << endl << (*pRes) ; + pRes->Dump(); + GlobalDispatcher->addResult(pRes) ; } diff --git a/monitord/MonitorModules.h b/monitord/MonitorModules.h index 925519d..fb5dd6d 100644 --- a/monitord/MonitorModules.h +++ b/monitord/MonitorModules.h @@ -74,7 +74,7 @@ float sum = 0; unsigned int i; - FILE_LOG(logDEBUG2) << "processing mac() Block with size=" << size ; + LOG_DEBUG("processing mac() Block with size=" << size) for (i = 0; i < size; i++) sum += (*a++) * (*b++); return sum; diff --git a/monitord/MonitorModulesResults.cpp b/monitord/MonitorModulesResults.cpp index b4f1ab1..bc3c79c 100644 --- a/monitord/MonitorModulesResults.cpp +++ b/monitord/MonitorModulesResults.cpp @@ -33,14 +33,11 @@ target.m_Items = m_Items ; } - -ostream& operator<<(ostream & os, ModuleResultBase & m) -{ - for (ResultItemsMap::iterator iter=m.m_Items.begin(); iter!=m.m_Items.end(); ++iter) - { - os << iter->first << " = \"" << iter->second << "\"" << endl ; - } - return os ; +void ModuleResultBase::Dump() { + for (ResultItemsMap::iterator iter=m_Items.begin(); iter!=m_Items.end(); ++iter) + { + LOG_DEBUG(iter->first << " = \"" << iter->second << "\""); + } } //---------------------------------------------------------------- @@ -48,7 +45,7 @@ // MonitorResultsDispatcher::MonitorResultsDispatcher() { - FILE_LOG(logDEBUG) << "Dispatcher startet" ; + LOG_DEBUG("Dispatcher startet") if ( memLockCreate( 12346, & m_MemLock) < 0) { ThrowMonitorException("Dispatcher: memLockCreate failed") ; @@ -91,9 +88,9 @@ do { - FILE_LOG(logDEBUG1) << "Dispatcher waiting" ; + LOG_DEBUG("Dispatcher waiting") m_Signal.WaitForSignal() ; // Auf neue Daten warten ... - FILE_LOG(logDEBUG1) << "Dispatcher running" ; + LOG_DEBUG("Dispatcher running") while (m_Results.size()>0) { @@ -101,7 +98,7 @@ memLock(m_MemLock) ; for (MODULERESULTSET::iterator i=m_Results.begin(); i MODULERESULTSET ; diff --git a/monitord/MonitorSignals.cpp b/monitord/MonitorSignals.cpp index 03ea8ff..d774c8c 100644 --- a/monitord/MonitorSignals.cpp +++ b/monitord/MonitorSignals.cpp @@ -19,7 +19,7 @@ ThrowMonitorException("error initialising pthreads Condition/Mutex") ; } #endif - FILE_LOG(logDEBUG1) << "Signal erstellt..." ; + LOG_DEBUG("Signal erstellt...") } MonitorBlockingSignal::~MonitorBlockingSignal() @@ -45,7 +45,7 @@ void MonitorBlockingSignal::SetSignal() { - FILE_LOG(logDEBUG1) << "Signal wird gesetzt" ; + LOG_DEBUG("Signal wird gesetzt") #ifdef WIN32 if (m_Handle) SetEvent(m_Handle); @@ -58,7 +58,7 @@ void MonitorBlockingSignal::WaitForSignal() { - FILE_LOG(logDEBUG1) << "Waiting for signal" ; + LOG_DEBUG("Waiting for signal") #ifdef WIN32 if (m_Handle) WaitForSingleObject(m_Handle,INFINITE) ; @@ -67,5 +67,5 @@ #else pthread_cond_wait(&m_ptCondition,&m_ptLock) ; #endif - FILE_LOG(logDEBUG1) << "Waiting for signal beendet" ; + LOG_DEBUG("Waiting for signal beendet") } diff --git a/monitord/PluginThread.cpp b/monitord/PluginThread.cpp index 078a701..28fb507 100644 --- a/monitord/PluginThread.cpp +++ b/monitord/PluginThread.cpp @@ -13,7 +13,7 @@ PluginThread::PluginThread() : ThreadBase(-1) { - FILE_LOG(logDEBUG) << "Erstellt PT:" ; + LOG_DEBUG("Erstellt PT:") m_iLockNum=-1 ; m_plugin=NULL ; m_bStop=false ; @@ -27,11 +27,11 @@ char dllname[255] ; memset(dllname,0,255) ; strncpy(dllname,dllfile.c_str(),255) ; - FILE_LOG(logDEBUG) << "DLL Name:" << dllname ; + LOG_DEBUG("DLL Name:" << dllname) dll= new DLLFactory(dllname); - FILE_LOG(logDEBUG) << "done" ; + LOG_DEBUG("done") // // If it worked we should have dll.factory pointing // to a subclass of PlugInFactory @@ -76,7 +76,7 @@ ModuleResultBase* pRes ; - FILE_LOG(logINFO) << "PluginThread starting" ; + LOG_INFO("PluginThread starting") this->ThreadStarted() ; // Erstmal Bescheid geben, dass wir laufen createLock() ; @@ -87,7 +87,7 @@ memLock(m_Lock) ; while (m_queue.size()>0) { - FILE_LOG(logDEBUG) << "plugin processing - size=" << m_queue.size() ; + LOG_DEBUG("plugin processing - size=" << m_queue.size()) pRes=m_queue.back() ; m_queue.pop_back() ; memUnlock(m_Lock) ; @@ -103,7 +103,7 @@ memUnlock(m_Lock) ; } - FILE_LOG(logINFO) << "PluginThread was stopped" ; + LOG_INFO("PluginThread was stopped") m_plugin->quitProcessing(); return NULL; @@ -129,7 +129,7 @@ { m_queue.insert(m_queue.begin(),localResult) ; } else { - FILE_LOG(logERROR) << "max plugin queue size exceeded. moduleresult not queued" ; + LOG_ERROR("max plugin queue size exceeded. moduleresult not queued") } memUnlock(m_Lock) ; @@ -146,8 +146,6 @@ MonitorPluginsManager::MonitorPluginsManager() { - // FILE_LOG(logINFO) << "PluginManager erstellt" ; - if ( memLockCreate( 12348, & m_MemLock) < 0) { ThrowMonitorException("PluginManager: memLockCreate failed") ; } @@ -175,15 +173,15 @@ if (lua_pcall(L, 0, 0, 0)) { - FILE_LOG(logERROR) << "LUA test fehlgeschlagen" << std::endl ; + LOG_ERROR("LUA test fehlgeschlagen" << std::endl) } m_bUseLUAScript=true ; - FILE_LOG(logINFO) << "Successfully loaded LUA filter: " << pluginFilterFileName ; + LOG_INFO("Successfully loaded LUA filter: " << pluginFilterFileName) } catch (const std::string &e) { - FILE_LOG(logERROR) << "Error loading lua dispatcher script: " << e; + LOG_ERROR("Error loading lua dispatcher script: " << e) } return m_bUseLUAScript ; #endif @@ -270,19 +268,19 @@ /* do the call (2 arguments, 1 result) */ if (lua_pcall(L, 0, LUA_MULTRET, 0) != 0) { - FILE_LOG(logERROR) << "Fehler beim Aufruf lua dispatcher script:" << lua_tostring(L, -1); + LOG_ERROR("Fehler beim Aufruf lua dispatcher script:" << lua_tostring(L, -1)) //error(L, "error running function `f': %s", // lua_tostring(L, -1)); } /* retrieve result */ if (!lua_isnumber(L, -1)) { - FILE_LOG(logERROR) << "nicht-numerische Antwort vom lua dispatcher script" ; + LOG_ERROR("nicht-numerische Antwort vom lua dispatcher script") //error(L, "function `f' must return a number"); } z = lua_tonumber(L, -1); lua_pop(L, 1); /* pop returned value */ - FILE_LOG(logDEBUG1) << "lua Result (global dispatcher)" << z ; + LOG_DEBUG("lua Result (global dispatcher)" << z) if (z==1) m_bSkipDispatching=true ; } @@ -301,14 +299,14 @@ PluginThread* pt=new PluginThread() ; if (pt->initPlugin(4000,dllfile,pConfig)) { - FILE_LOG(logDEBUG) << "startet plugin " << dllfile ; + LOG_DEBUG("startet plugin " << dllfile) pt->Start() ; pt->setPluginName(pluginName) ; addModule(pt) ; return true ; } else { - FILE_LOG(logERROR) << "DLL Factory konnte nicht initialisiert werden !" ; + LOG_ERROR("DLL Factory konnte nicht initialisiert werden !") return false ; } } @@ -323,7 +321,7 @@ XMLNode *pParameters ; XMLNode pluginNode; // = pConfig->getChildNode("plugin",sndCard) ; - FILE_LOG(logINFO) << "reading plugin configuration" ; + LOG_INFO("reading plugin configuration") int nPlugins=pConfig->nChildNode("plugin"); for (int plugin=0;pluginIsRunning()) { - FILE_LOG(logDEBUG) << "L: Nachricht wird versendet ..." ; + LOG_DEBUG("L: Nachricht wird versendet ...") msg.pThread->addOutputText(msg.message); } } @@ -93,7 +93,7 @@ { if (msg.pThread->IsRunning()) { - FILE_LOG(logDEBUG) << "R: Nachricht wird versendet ..." ; + LOG_DEBUG("R: Nachricht wird versendet ...") msg.pThread->addOutputText(msg.message); } } @@ -149,11 +149,11 @@ { if (pConfig->m_sndConfig[cardnum].iAktiv==1) { - FILE_LOG(logINFO) << "creating decoders for soundcard #" << cardnum ; + LOG_INFO("creating decoders for soundcard #" << cardnum) // FMS ? if (pConfig->m_sndConfig[cardnum].iFMS[0]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "L:FMS" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "L:FMS") newModule= (MonitorModule*) new MonitorModuleFMS(sampleRate, &(pConfig->m_sndConfig[cardnum].configFMS[0])) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName0) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -163,7 +163,7 @@ if (pConfig->m_sndConfig[cardnum].iFMS[1]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "R:FMS" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "R:FMS") newModule= (MonitorModule*) new MonitorModuleFMS(sampleRate,&(pConfig->m_sndConfig[cardnum].configFMS[1])) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName1) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -175,7 +175,7 @@ // ZVEI if (pConfig->m_sndConfig[cardnum].iZVEI[0]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "L:ZVEI" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "L:ZVEI") newModule= (MonitorModule*) new MonitorModuleZVEI(sampleRate,&(pConfig->m_sndConfig[cardnum].configZVEI[0])) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName0) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -186,7 +186,7 @@ if (pConfig->m_sndConfig[cardnum].iZVEI[1]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "R:ZVEI" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "R:ZVEI") newModule= (MonitorModule*) new MonitorModuleZVEI(sampleRate,&(pConfig->m_sndConfig[cardnum].configZVEI[1])) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName1) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -198,7 +198,7 @@ // POC512 if (pConfig->m_sndConfig[cardnum].iPOC512[0]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "L:POC512" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "L:POC512") //newModule= (MonitorModule*) new MonitorModulePocsag512(sampleRate,&(pConfig->m_sndConfig[cardnum].configPOC512[0])) ; newModule= (MonitorModule*) new MonitorModulePocsag512(sampleRate,1,0) ; //(sampleRate,1,0) ; @@ -212,7 +212,7 @@ if (pConfig->m_sndConfig[cardnum].iPOC512[1]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "R:POC512" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "R:POC512") newModule= (MonitorModule*) new MonitorModulePocsag512(sampleRate,1,0) ; //newModule= (MonitorModule*) new MonitorModulePocsag512(&(pConfig->m_sndConfig[cardnum].configPOC512[1])) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName1) ; @@ -225,7 +225,7 @@ // POC1200 if (pConfig->m_sndConfig[cardnum].iPOC1200[0]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "L:POC1200" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "L:POC1200") newModule= (MonitorModule*) new MonitorModulePocsag1200(sampleRate,1,0) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName0) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -236,7 +236,7 @@ if (pConfig->m_sndConfig[cardnum].iPOC1200[1]==1) { - FILE_LOG(logINFO) << "creating decoder for soundcard #" << cardnum << "R:POC1200" ; + LOG_INFO("creating decoder for soundcard #" << cardnum << "R:POC1200") newModule= (MonitorModule*) new MonitorModulePocsag1200(sampleRate,1,0) ; newModule->setChannelName(pConfig->m_sndConfig[cardnum].sChannelName1) ; newModule->setServerName(pConfig->m_sMonitordName) ; @@ -245,12 +245,12 @@ m_ModulesRechts.insert(m_ModulesRechts.end(),newModule) ; } } else { - FILE_LOG(logINFO) << "skipping decoders for soundcard #" << cardnum << " : card not active !" ; + LOG_INFO("skipping decoders for soundcard #" << cardnum << " : card not active !") } } catch (MonitorException e) { - FILE_LOG(logERROR) << "Error initialising decoder modules for soundcard #" << cardnum << ":" << e.what() ; + LOG_ERROR("Error initialising decoder modules for soundcard #" << cardnum << ":" << e.what()) return false ; } return true ; @@ -260,9 +260,9 @@ bool CSndPipe::loadPlugins(MonitorConfiguration* pConfig, XMLNode configLeft, XMLNode configRight) { - FILE_LOG(logINFO) << "loading audioplugins for left channel" ; + LOG_INFO("loading audioplugins for left channel") loadPlugins(pConfig, configLeft,m_pluginsLeft,2*m_cardNum+0) ; - FILE_LOG(logINFO) << "loading audioplugins for right channel" ; + LOG_INFO("loading audioplugins for right channel") loadPlugins(pConfig, configRight,m_pluginsRight,2*m_cardNum+1) ; return true ; @@ -280,7 +280,7 @@ if (!((pluginNode=config.getChildNode("plugin",plugin))).isEmpty()) { file=getNodeText(pluginNode,"file","") ; - FILE_LOG(logINFO) << "plugin file:" << plugin << "=" << file ; + LOG_INFO("plugin file:" << plugin << "=" << file) if (file.size()>0) { loadPlugin(pConfig, file,pluginNode,plugins,channelNum) ; @@ -301,7 +301,7 @@ if ((i<=MAXPLUGINS) &&(plugins[i]==NULL)) { - FILE_LOG(logINFO) << "Plugin# " << i << ": loading audio plugin using: " << dllfile ; + LOG_INFO("Plugin# " << i << ": loading audio plugin using: " << dllfile) #ifdef WIN32 static DLLFactory dll( dllfile.c_str() ); #else @@ -322,7 +322,7 @@ plugins[i]->InitAudioProcessing(pConfig, config, channelNum) ; } } else { - FILE_LOG(logERROR) << "Error plugin Factory from file " << dllfile ; + LOG_ERROR("Error plugin Factory from file " << dllfile) } } return true ; diff --git a/monitord/SocketServer.cpp b/monitord/SocketServer.cpp index 54a014e..f26fd5e 100644 --- a/monitord/SocketServer.cpp +++ b/monitord/SocketServer.cpp @@ -75,15 +75,15 @@ if (lua_pcall(L, 0, 0, 0)) { - FILE_LOG(logERROR) << "LUA test fehlgeschlagen" << endl ; + LOG_ERROR("LUA test fehlgeschlagen" << endl ) } m_bUseLUAScript=true ; - FILE_LOG(logINFO) << "Successfully loaded LUA filter: " << FilterFileName ; + LOG_INFO("Successfully loaded LUA filter: " << FilterFileName ) } catch (const std::string &e) { - FILE_LOG(logERROR) << "Error loading lua script: " << e; + LOG_ERROR("Error loading lua script: " << e) } #endif @@ -268,7 +268,7 @@ socklen_t sin_size = sizeof (sockaddr_in); int fd = accept(m_sock,(sockaddr*) &socketThread[useSocket]->m_client,&sin_size); - FILE_LOG(logINFO) << "new connection from " << inet_ntoa(socketThread[useSocket]->m_client.sin_addr) ; + LOG_INFO("new connection from " << inet_ntoa(socketThread[useSocket]->m_client.sin_addr) ) // Thread mit dem oben angenommenen Socket starten socketThread[useSocket]->setFD(fd) ; @@ -281,16 +281,16 @@ closesocket( m_sock); // Alle Clients beenden - FILE_LOG(logINFO) << "Beende alle Clients" ; + LOG_INFO("Beende alle Clients" ) for (int i=0;iIsRunning()) { socketThread[i]->closeSocket() ; - FILE_LOG(logINFO) << i << ": closesocket done" ; + LOG_INFO(i << ": closesocket done" ) socketThread[i]->Kill() ; - FILE_LOG(logINFO) << i << ": kill done" ; + LOG_INFO(i << ": kill done" ) } } @@ -435,19 +435,19 @@ /* do the call (2 arguments, 1 result) */ if (lua_pcall(L, 0, LUA_MULTRET, 0) != 0) { - FILE_LOG(logERROR) << "Fehler beim Aufruf lua dispatcher script:" << lua_tostring(L, -1); + LOG_ERROR("Fehler beim Aufruf lua dispatcher script:" << lua_tostring(L, -1)) //error(L, "error running function `f': %s", // lua_tostring(L, -1)); } /* retrieve result */ if (!lua_isnumber(L, -1)) { - FILE_LOG(logERROR) << "nicht-numerische Antwort vom lua dispatcher script" ; + LOG_ERROR("nicht-numerische Antwort vom lua dispatcher script" ) //error(L, "function `f' must return a number"); } z = lua_tonumber(L, -1); lua_pop(L, 1); /* pop returned value */ - FILE_LOG(logDEBUG1) << "lua Result (global dispatcher)" << z ; + LOG_DEBUG("lua Result (global dispatcher)" << z) if (z==1) m_bSkipDispatching=true ; } @@ -548,7 +548,7 @@ createLock() ; createSocket() ; - FILE_LOG(logINFO) << "SocketThreads exits" ; + LOG_INFO("SocketThreads exits" ) releaseLock() ; return NULL; @@ -617,7 +617,7 @@ unsigned int len=send( m_fd, something.c_str(), something.length(), 0); if (len!=something.length()) { - FILE_LOG(logERROR) << "error sending date to client. thread exiting" ; + LOG_ERROR("error sending date to client. thread exiting" ) doLogout() ; } } @@ -627,7 +627,7 @@ unsigned int len = send( m_fd, something, strlen(something), 0); if (len!=strlen(something)) { - FILE_LOG(logERROR) << "error sending date to client. thread exiting" ; + LOG_ERROR("error sending date to client. thread exiting" ) doLogout() ; } } @@ -674,7 +674,7 @@ // Gültige IP Adresse, die sich nicht anmelden muss ? if (m_MonitorConfiguration->IsValidLogin("","",this->m_sClientIP)) { - FILE_LOG(logINFO) << "login authentication (ip allowed): " << m_sClientIP ; + LOG_INFO("login authentication (ip allowed): " << m_sClientIP ) this->m_authenticated=true ; } @@ -718,20 +718,20 @@ if (FD_ISSET(m_fd,&fdset)>0) // Socket ereignis ? { - FILE_LOG(logDEBUG) << "Socket reports read event" ; + LOG_DEBUG("Socket reports read event") result=1 ; } if (FD_ISSET(m_fd,&fdset_write)>0) // Problem ? { - FILE_LOG(logDEBUG) << "Socket reports write event" ; + LOG_DEBUG("Socket reports write event") result=0 ; //m_exitThread=true ; } if (FD_ISSET(m_fd,&fdset_exceptions)>0) // Problem ? { - FILE_LOG(logDEBUG) << "Socket reports exception event" ; + LOG_DEBUG("Socket reports exception event") result=0 ; m_exitThread=true ; } @@ -744,7 +744,7 @@ gelesen=recv (m_fd, buffer, RECV_BUFFER-1, 0) ; if (gelesen<=0) // Nix am Port, aber doch Port Event ? { - FILE_LOG(logINFO) << "recv()<=0 => socketthread exiting" ; + LOG_INFO("recv()<=0 => socketthread exiting" ) m_exitThread=true ; } buffer[gelesen]='\0'; @@ -848,7 +848,7 @@ MonitorSocketsManager::MonitorSocketsManager() { - FILE_LOG(logDEBUG) << "SocketManager erstellt" ; + LOG_DEBUG("SocketManager erstellt") if ( memLockCreate( 12347, & m_MemLock) < 0) { ThrowMonitorException("SocketsManager: memLockCreate failed") ; diff --git a/monitord/SocketThreadCrusader.cpp b/monitord/SocketThreadCrusader.cpp index 821931c..7198514 100644 --- a/monitord/SocketThreadCrusader.cpp +++ b/monitord/SocketThreadCrusader.cpp @@ -110,7 +110,7 @@ /* Status im Crusader manuell gesetzt: * 23.07.08#![]!#22:19:36#![]!#93185811#![]!#7#![]!#true#![]!#false#![]!#3#![]!#1#![]!#false#![]!#true#![]!#-1#![]!#7 TelegrammText#![]!# */ - FILE_LOG (logDEBUG) << "manueller Status von Crusader Client empfangen."; + LOG_DEBUG("manueller Status von Crusader Client empfangen.") /* es wird nur FMS betrachtet */ pfms->set ("typ", "fms"); @@ -156,11 +156,12 @@ position = Kommando.find_first_of(CRUSADER_DELIMITER, position) + 6; pfms->set ("textuebertragung", Kommando.substr(position, Kommando.find_first_of(CRUSADER_DELIMITER, position) - position)); - FILE_LOG(logDEBUG) << "Debug(FMS vom Crusader):" << endl << (*pfms); + LOG_DEBUG("Debug(FMS vom Crusader):") + pfms->Dump(); GlobalDispatcher->addResult (pfms); } else { - FILE_LOG (logDEBUG) << "received from Crusader: " << m_CommandBuffer ; + LOG_DEBUG("received from Crusader: " << m_CommandBuffer) } } @@ -169,9 +170,9 @@ if (m_MonitorConfiguration->IsValidLogin(m_MonitorConfiguration->m_crusaderUsername,password,m_sClientIP)) { m_authenticated=true ; - FILE_LOG(logINFO) << "login accepted (crusader pw allowed): from ip " << m_sClientIP ; + LOG_INFO("login accepted (crusader pw allowed): from ip " << m_sClientIP) } else { - FILE_LOG(logINFO) << "login denied (crusader pw not allowed): " << password << " from ip " << m_sClientIP ; + LOG_INFO("login denied (crusader pw not allowed): " << password << " from ip " << m_sClientIP) } } diff --git a/monitord/SocketThreadFMS32.cpp b/monitord/SocketThreadFMS32.cpp index 05185a8..71a8543 100644 --- a/monitord/SocketThreadFMS32.cpp +++ b/monitord/SocketThreadFMS32.cpp @@ -23,15 +23,15 @@ std::string Kommando=m_CommandBuffer; if (Kommando == "AllFMS") { - FILE_LOG (logDEBUG) << "FMS32 Kommando nicht implementiert (�bertragung aktueller Fahrzeugstatus aller Fahrzeuge)."; + LOG_DEBUG("FMS32 Kommando nicht implementiert (�bertragung aktueller Fahrzeugstatus aller Fahrzeuge).") } else if (Kommando == "GetAlarmListe") { - FILE_LOG (logDEBUG) << "FMS32 Kommando nicht implementiert (GetAlarmListe)."; + LOG_DEBUG("FMS32 Kommando nicht implementiert (GetAlarmListe).") } else if (Kommando.substr(0, 12) == "GetFMSListe\t") { - FILE_LOG (logDEBUG) << "FMS32 Kommando nicht implementiert (�bertragung Statuswechsel der letzten n Stunden)."; + LOG_DEBUG("FMS32 Kommando nicht implementiert (�bertragung Statuswechsel der letzten n Stunden).") } else if (Kommando.substr(0, 12) == "GetPOCListe\t") { - FILE_LOG (logDEBUG) << "FMS32 Kommando nicht implementiert (�bertragung POCSAG Rufe der letzten n Stunden)."; + LOG_DEBUG( "FMS32 Kommando nicht implementiert (�bertragung POCSAG Rufe der letzten n Stunden).") } else { - FILE_LOG (logDEBUG) << "received from FMS32: " << m_CommandBuffer; + LOG_DEBUG("received from FMS32: " << m_CommandBuffer) } return; @@ -114,7 +114,7 @@ catch (BadConversion) { sub=0 ; - FILE_LOG (logERROR) << "Error converting subaddress : " << Result["sub"] ; + LOG_ERROR("Error converting subaddress : " << Result["sub"]) } subString=convertIntToString(sub) ; diff --git a/monitord/SocketThreadMonitord.cpp b/monitord/SocketThreadMonitord.cpp index 409ddd6..94c1885 100644 --- a/monitord/SocketThreadMonitord.cpp +++ b/monitord/SocketThreadMonitord.cpp @@ -117,12 +117,12 @@ int cmd ; try { - FILE_LOG(logDEBUG) << "command from client: " << m_cmdString ; + LOG_DEBUG("command from client: " << m_cmdString) cmd = convertToInt(m_cmdString) ; } catch (std::runtime_error err) { - FILE_LOG(logERROR) << "Fehler bei der Cmd Konvertierung: " << m_cmdString ; + LOG_ERROR("Fehler bei der Cmd Konvertierung: " << m_cmdString) cmd=-1 ; say(illegalFormatString) ; } @@ -270,7 +270,7 @@ int sndCardNum =channel / 2 ; int sndCardLeftRight=channel % 2 ; - FILE_LOG(logDEBUG) << "Starte Aufnahme mit" << seconds << " Sekunden" << " auf Karte " << sndCardNum << ", Kanal=" << sndCardLeftRight << endl ; + LOG_DEBUG( "Starte Aufnahme mit" << seconds << " Sekunden" << " auf Karte " << sndCardNum << ", Kanal=" << sndCardLeftRight << endl) std::string command=std::string("RECORD:" + convertIntToString(seconds)+ ":") + convertIntToString(channel) ; #if 0 /* FIXME mu� noch umstrukturiert werden */ std::string resultString =m_monitor.m_sndIn[sndCardNum].PluginCommand(sndCardLeftRight,command,this); @@ -317,18 +317,18 @@ { m_authenticated=true ; m_loginname=loginname ; - FILE_LOG(logINFO) << "login accepted (user allowed): " << m_loginname << " from ip " << m_sClientIP ; + LOG_INFO("login accepted (user allowed): " << m_loginname << " from ip " << m_sClientIP) say ("100\r\n") ; // Login OK } else { say ("101:003\r\n") ; // Benutzername falsch - FILE_LOG(logINFO) <<"login denied: " << m_loginname << " from ip " << m_sClientIP ; + LOG_INFO("login denied: " << m_loginname << " from ip " << m_sClientIP) } } else { say ("101:008\r\n") ; // Falsche Protokollversion - FILE_LOG(logINFO) <<"login denied, incorrect protocol version: " << protocol << " from ip: " << m_sClientIP << " with username: " << loginname ; + LOG_INFO("login denied, incorrect protocol version: " << protocol << " from ip: " << m_sClientIP << " with username: " << loginname) } } else { - FILE_LOG(logINFO) << "login with too few arguments detected" ; + LOG_INFO("login with too few arguments detected") say ("101:004;TOO FEW ARGUMENTS\r\n") ; // Fehler: Anfrage nicht verstanden ! } } diff --git a/monitord/plugins/dll-elf.cpp b/monitord/plugins/dll-elf.cpp index aa1c36d..2db007a 100644 --- a/monitord/plugins/dll-elf.cpp +++ b/monitord/plugins/dll-elf.cpp @@ -12,7 +12,7 @@ h=dlopen( fname, RTLD_NOW ); if (h==NULL) { - FILE_LOG(logERROR) << "error loading library file \"" << fname << "\"" ; + LOG_ERROR("error loading library file \"" << fname << "\"" ) } err=dlerror(); } diff --git a/monitord/plugins/dll-win32.cpp b/monitord/plugins/dll-win32.cpp index 629f31f..ae1daca 100644 --- a/monitord/plugins/dll-win32.cpp +++ b/monitord/plugins/dll-win32.cpp @@ -8,9 +8,9 @@ DLLManager::DLLManager( const char *fname ) { // Try to open the library now and get any error message. - FILE_LOG(logDEBUG) << "calling LoadLibrary.." ; + LOG_DEBUG("calling LoadLibrary..") h = LoadLibrary(fname); - FILE_LOG(logDEBUG) << "LoadLib done." ; + LOG_DEBUG("LoadLib done.") if (h == NULL) { @@ -27,7 +27,7 @@ 0, /* Min/Max Buffer size */ NULL); /* Arguments */ - FILE_LOG(logERROR) << "Error loading library \"" << fname << "\":" << err ; + LOG_ERROR("Error loading library \"" << fname << "\":" << err ) } else { @@ -100,7 +100,7 @@ { GetSymbol( (void **)&factory_func, factory ? factory : "factory0" ); } else { - FILE_LOG(logERROR) << "Lasterror=" << LastError() ; + LOG_ERROR("Lasterror=" << LastError() ) } } diff --git a/monitord/plugins/libmplugin_activemq.cpp b/monitord/plugins/libmplugin_activemq.cpp index cacb55a..8e05e15 100644 --- a/monitord/plugins/libmplugin_activemq.cpp +++ b/monitord/plugins/libmplugin_activemq.cpp @@ -110,15 +110,15 @@ void MonitorPlugInActiveMQ::Show() { - FILE_LOG(logINFO) << "MonitorActiveMQPlugin successfully loaded" ; + LOG_INFO("MonitorActiveMQPlugin successfully loaded" ) } bool MonitorPlugInActiveMQ::processResult(class ModuleResultBase *pRes) { - FILE_LOG(logDEBUG) << "apachemq: processing Result..."; + LOG_DEBUG("apachemq: processing Result...") if (m_bConnected == false) { - FILE_LOG(logERROR) << "apachmq: ignoring message 'cause no active connection"; + LOG_ERROR("apachmq: ignoring message 'cause no active connection") return false; } @@ -130,11 +130,11 @@ std::string type = (*pRes)["typ"]; if (m_topics.find(type) == m_topics.end()) { - FILE_LOG(logERROR) << "apachemq: received type " << type << " which is not registered"; + LOG_ERROR("apachemq: received type " << type << " which is not registered") return false; } - FILE_LOG(logINFO) << "Preparing new message"; + LOG_INFO("Preparing new message") TopicInfo* topicInfo = (m_topics.find(type))->second; TextMessage* message = m_session->createTextMessage(); @@ -148,7 +148,7 @@ topicInfo->producer->send(message); - FILE_LOG(logINFO) << "message sent"; + LOG_INFO("message sent") delete message; @@ -157,27 +157,16 @@ void MonitorPlugInActiveMQ::initializeConfiguration(XMLNode config) { - FILE_LOG(logDEBUG) << "Reading broker URI"; m_brokerUri = getNodeText(config, ACTIVEMQ_XMLNODE_BROKERURI, "tcp://127.0.0.1:61616"); - FILE_LOG(logDEBUG) << "Reading username:"; m_username = getNodeText(config, ACTIVEMQ_XMLNODE_USERNAME, ""); - FILE_LOG(logDEBUG) << "Reading password"; m_password = getNodeText(config, ACTIVEMQ_XMLNODE_PASSWORD, ""); - FILE_LOG(logDEBUG) << "Reading clientId"; m_clientId = getNodeText(config, ACTIVEMQ_XMLNODE_CLIENTID, ""); - FILE_LOG(logDEBUG) << "Reading sendTimeout"; m_sendTimeout = getNodeInt(config, ACTIVEMQ_XMLNODE_SENDTIMEOUT, 0); - FILE_LOG(logDEBUG) << "Reading closeTimeout"; m_closeTimeout = getNodeInt(config, ACTIVEMQ_XMLNODE_CLOSETIMEOUT, 0); - FILE_LOG(logDEBUG) << "Reading producerWindowSize"; m_producerWindowSize = getNodeInt(config, ACTIVEMQ_XMLNODE_PRODUCERWINDOWSIZE, 0); - FILE_LOG(logDEBUG) << "Reading bUseCompression"; m_bUseCompression = getNodeBool(config, ACTIVEMQ_XMLNODE_USECOMPRESSION, false); - FILE_LOG(logDEBUG) << "Reading bClientAck"; m_bClientAck = getNodeBool(config, ACTIVEMQ_XMLNODE_CLIENTACK, false); - FILE_LOG(logDEBUG) << "Reading logFile"; std::string logFile = getNodeText(config, ACTIVEMQ_XMLNODE_LOGFILE, "screen"); - FILE_LOG(logDEBUG) << "Reading logLevel"; std::string logLevel = getNodeText(config, ACTIVEMQ_XMLNODE_LOGLEVEL, "INFO"); #ifdef WIN32 @@ -187,7 +176,7 @@ } FILELog::ReportingLevel() = FILELog::FromString(logLevel); - FILE_LOG(logINFO) << "logging started"; + LOG_INFO("logging started") #endif } @@ -223,7 +212,7 @@ connectionFactory->setCloseTimeout(m_closeTimeout); connectionFactory->setProducerWindowSize(m_producerWindowSize); - FILE_LOG(logDEBUG) << "Connection factory initialized"; + LOG_DEBUG("Connection factory initialized") } bool MonitorPlugInActiveMQ::initializeActiveMqConnection() @@ -246,11 +235,11 @@ m_bConnected = true; } catch (CMSException& e) { - FILE_LOG(logERROR) << "Could not connect to messaging queue \"" << m_brokerUri << "\" with username=\"" << m_username << "\""; + LOG_ERROR("Could not connect to messaging queue \"" << m_brokerUri << "\" with username=\"" << m_username << "\"") m_bConnected = false; } - FILE_LOG(logDEBUG) << "Connection initialized"; + LOG_DEBUG("Connection initialized") return m_bConnected; } @@ -303,10 +292,10 @@ pTopicInfo->producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT); } - FILE_LOG(logINFO) << "Topic destination \"" << pTopicInfo->destination << "\" created"; + LOG_INFO("Topic destination \"" << pTopicInfo->destination << "\" created") } - FILE_LOG(logINFO) << "Topics initialized"; + LOG_INFO("Topics initialized") m_bTopicsInitialized = true; } diff --git a/monitord/plugins/libmplugin_audiorecorder.cpp b/monitord/plugins/libmplugin_audiorecorder.cpp index e789855..d779c51 100644 --- a/monitord/plugins/libmplugin_audiorecorder.cpp +++ b/monitord/plugins/libmplugin_audiorecorder.cpp @@ -60,6 +60,7 @@ logLevel=getNodeText(parameters,"loglevel","INFO") ; } + // TODO log4cxx #ifdef WIN32 if (!(logFile=="screen")) { @@ -67,14 +68,14 @@ Output2FILE::Stream() = pFile; } FILELog::ReportingLevel() = FILELog::FromString(logLevel); - FILE_LOG(logINFO) << "logging started"; + LOG_INFO("logging started") #endif #ifdef HAVE_LIBMP3LAME try { - FILE_LOG(logINFO) << "enabling lame mp3 support" ; - FILE_LOG(logINFO) << "Using MP3Lame Lib Version: " << get_lame_version() ; + LOG_INFO("enabling lame mp3 support") + LOG_INFO("Using MP3Lame Lib Version: " << get_lame_version()) gfp=lame_init() ; if (gfp==NULL) @@ -99,7 +100,7 @@ } } catch (MonitorException e) { - FILE_LOG(logERROR) << e.what() ; + LOG_ERROR(e.what()) } #endif @@ -108,7 +109,7 @@ virtual void Show() { - FILE_LOG(logINFO) << "MonitorAudioPluginRecorder successfully loaded" ; + LOG_INFO("MonitorAudioPluginRecorder successfully loaded") } virtual void WriteRAWToFile (FILE *pFile,SHORT buffer[],unsigned int bufferSize) @@ -116,7 +117,7 @@ size_t len=fwrite(buffer, sizeof(SHORT), bufferSize,pFile); if (len!=bufferSize) { - FILE_LOG(logERROR) << "Fehler beim Schreiben: " << len << " statt " << bufferSize ; + LOG_ERROR("Fehler beim Schreiben: " << len << " statt " << bufferSize) // Fehler beim Schreiben ? } } @@ -126,7 +127,7 @@ size_t len=fwrite(buffer, sizeof(unsigned char), bufferSize,pFile); if (len!=bufferSize) { - FILE_LOG(logERROR) << "Fehler beim Schreiben: " << len << " statt " << bufferSize ; + LOG_ERROR("Fehler beim Schreiben: " << len << " statt " << bufferSize) // Fehler beim Schreiben ? } } @@ -196,10 +197,10 @@ void StartRecording(int jobID,std::string fname,int Sekunden) { - FILE_LOG(logINFO) << "Starte Aufnahme .." ; + LOG_INFO("Starte Aufnahme ..") // Aufnahmedatei erzeugen - FILE_LOG(logINFO) << "Starte mit dauer:" << Sekunden ; + LOG_INFO("Starte mit dauer:" << Sekunden) if (fname.size()>0) { // Dateiname wurde vorgegeben @@ -211,11 +212,11 @@ FILE * f_File = fopen(fname.c_str(), "wb"); if(f_File==NULL) { - FILE_LOG(logERROR) << "File ist NICHT erstellt" ; + LOG_ERROR("File ist NICHT erstellt") } else { - FILE_LOG(logERROR) << "File ist erstellt"<< fname ; + LOG_ERROR("File ist erstellt"<< fname) } // Aufnahme starten, Daten beim Job hinterlegen @@ -231,7 +232,7 @@ void StopRecording(int jobID) { - FILE_LOG(logINFO) << "Aufnahme beendet" ; + LOG_INFO("Aufnahme beendet") FILE* pFile=(FILE*) getCustomValue(jobID) ; std::string fname=getInfoText(jobID) ; @@ -248,12 +249,12 @@ std::string fname ; int Sekunden=0 ; - FILE_LOG(logINFO) << "Kommando: " << command ; + LOG_INFO("Kommando: " << command) parseCommand(command) ; for (int i=0;i<10;i++) { - FILE_LOG(logINFO) << "Param " << i << ":" << m_param[i] ; + LOG_INFO("Param " << i << ":" << m_param[i]) } if (m_param[0]=="RECORD") //RECORD: @@ -263,36 +264,36 @@ try { Sekunden=convertToInt(m_param[1]) ; - FILE_LOG(logINFO) << "Sekunden als param:" << m_param[1] ; - FILE_LOG(logINFO) << "Sekunden als int:" << Sekunden ; + LOG_INFO("Sekunden als param:" << m_param[1]) + LOG_INFO("Sekunden als int:" << Sekunden) } catch (BadConversion e) { - FILE_LOG(logERROR) << "Fehler bei der Datenkonvertierung " << m_param[1] ; + LOG_ERROR("Fehler bei der Datenkonvertierung " << m_param[1]) Sekunden=60 ; } } int jobID=addClient(pClient) ; //< Auftraggeber, fuer callback mit Result - FILE_LOG(logINFO) << "jobID=" << jobID ; + LOG_INFO("jobID=" << jobID) // Laeuft mit der jobID schon eine Aufzeichnung ? // Wenn, dann keine neue starten, sondern nur verlaengern long SekundenAlterJob = getInfo(jobID) ; - FILE_LOG(logINFO) << "Zeitdauer alte Aufnahme:" << SekundenAlterJob ; + LOG_INFO("Zeitdauer alte Aufnahme:" << SekundenAlterJob) if (SekundenAlterJob>0) { // Nur die Zeit anpassen time_t curTime=time(NULL) ; time_t startTime=getTime1(jobID) ; - FILE_LOG(logDEBUG) << "Zeiten curTime+Sekunden:" << curTime+Sekunden ; - FILE_LOG(logDEBUG) << "Zeiten startTime+SekundenAlterJob:" << startTime+SekundenAlterJob ; + LOG_DEBUG("Zeiten curTime+Sekunden:" << curTime+Sekunden) + LOG_DEBUG("Zeiten startTime+SekundenAlterJob:" << startTime+SekundenAlterJob) if (curTime+Sekunden>startTime+SekundenAlterJob) { fname=getInfoText(jobID) ; Sekunden=curTime+Sekunden-startTime ; - FILE_LOG(logINFO) << "Aufnahme wird auf " << Sekunden << "verlaengert " ; + LOG_INFO("Aufnahme wird auf " << Sekunden << "verlaengert ") updateClient(jobID,getCustomValue(jobID),0,Sekunden,getInfoText(jobID),startTime) ; addThreadMessage(jobID,std::string("104:" +convertIntToString(m_channelNum)+ ":2:") + convertStringToHex(fname)) ; } @@ -308,7 +309,7 @@ strTime->tm_hour, strTime->tm_min, strTime->tm_sec) ; - FILE_LOG(logDEBUG) << zeitString ; + LOG_DEBUG(zeitString) if (m_paramCount<2) { diff --git a/monitord/plugins/libmplugin_audiorecorderSOX.cpp b/monitord/plugins/libmplugin_audiorecorderSOX.cpp index 9ddcf1b..7f21c24 100644 --- a/monitord/plugins/libmplugin_audiorecorderSOX.cpp +++ b/monitord/plugins/libmplugin_audiorecorderSOX.cpp @@ -59,8 +59,9 @@ FILE* pFile = fopen(logFile.c_str(), "a"); Output2FILE::Stream() = pFile; } + // TODO: log4cxx FILELog::ReportingLevel() = FILELog::FromString(logLevel); - FILE_LOG(logINFO) << "logging started"; + LOG_INFO("logging started"; #endif @@ -75,7 +76,7 @@ virtual void Show() { - FILE_LOG(logINFO) << "MonitorAudioPluginRecorder successfully loaded" ; + LOG_INFO("MonitorAudioPluginRecorder successfully loaded") } virtual void WriteToFile (FILE *pFile,unsigned char buffer[],unsigned int bufferSize) @@ -83,7 +84,7 @@ size_t len=fwrite(buffer, sizeof(unsigned char), bufferSize,pFile); if (len!=bufferSize) { - FILE_LOG(logERROR) << "Fehler beim Schreiben: " << len << " statt " << bufferSize ; + LOG_ERROR("Fehler beim Schreiben: " << len << " statt " << bufferSize) // Fehler beim Schreiben ? } } @@ -142,10 +143,10 @@ void StartRecording(int jobID,std::string fname,int Sekunden) { - FILE_LOG(logINFO) << "Starte Aufnahme .." ; + LOG_INFO("Starte Aufnahme ..") // Aufnahmedatei erzeugen - FILE_LOG(logINFO) << "Starte mit dauer:" << Sekunden ; + LOG_INFO("Starte mit dauer:" << Sekunden) if (fname.size()>0) { // Dateiname wurde vorgegeben @@ -179,11 +180,11 @@ 0) ; if(pFormat==NULL) { - FILE_LOG(logERROR) << "File ist NICHT erstellt" ; + LOG_ERROR("File ist NICHT erstellt") } else { - FILE_LOG(logERROR) << "File ist erstellt: "<< fname ; + LOG_ERROR("File ist erstellt: "<< fname) } // Aufnahme starten, Daten beim Job hinterlegen @@ -199,7 +200,7 @@ void StopRecording(int jobID) { - FILE_LOG(logINFO) << "Aufnahme beendet" ; + LOG_INFO("Aufnahme beendet") sox_format_t* pFormat=(sox_format_t*) getCustomValue(jobID) ; std::string fname=getInfoText(jobID) ; @@ -217,12 +218,12 @@ std::string fname ; int Sekunden=0 ; - FILE_LOG(logINFO) << "Kommando: " << command ; + LOG_INFO("Kommando: " << command) parseCommand(command) ; for (int i=0;i<10;i++) { - FILE_LOG(logINFO) << "Param " << i << ":" << m_param[i] ; + LOG_INFO("Param " << i << ":" << m_param[i]) } if (m_param[0]=="RECORD") //RECORD: @@ -232,36 +233,36 @@ try { Sekunden=convertToInt(m_param[1]) ; - FILE_LOG(logINFO) << "Sekunden als param:" << m_param[1] ; - FILE_LOG(logINFO) << "Sekunden als int:" << Sekunden ; + LOG_INFO("Sekunden als param:" << m_param[1]) + LOG_INFO("Sekunden als int:" << Sekunden) } catch (BadConversion e) { - FILE_LOG(logERROR) << "Fehler bei der Datenkonvertierung " << m_param[1] ; + LOG_ERROR("Fehler bei der Datenkonvertierung " << m_param[1]) Sekunden=60 ; } } int jobID=addClient(pClient) ; //< Auftraggeber, fuer callback mit Result - FILE_LOG(logINFO) << "jobID=" << jobID ; + LOG_INFO("jobID=" << jobID) // Laeuft mit der jobID schon eine Aufzeichnung ? // Wenn, dann keine neue starten, sondern nur verlaengern long SekundenAlterJob = getInfo(jobID) ; - FILE_LOG(logINFO) << "Zeitdauer alte Aufnahme:" << SekundenAlterJob ; + LOG_INFO("Zeitdauer alte Aufnahme:" << SekundenAlterJob) if (SekundenAlterJob>0) { // Nur die Zeit anpassen time_t curTime=time(NULL) ; time_t startTime=getTime1(jobID) ; - FILE_LOG(logDEBUG) << "Zeiten curTime+Sekunden:" << curTime+Sekunden ; - FILE_LOG(logDEBUG) << "Zeiten startTime+SekundenAlterJob:" << startTime+SekundenAlterJob ; + LOG_DEBUG( "Zeiten curTime+Sekunden:" << curTime+Sekunden ; + LOG_DEBUG( "Zeiten startTime+SekundenAlterJob:" << startTime+SekundenAlterJob ; if (curTime+Sekunden>startTime+SekundenAlterJob) { fname=getInfoText(jobID) ; Sekunden=curTime+Sekunden-startTime ; - FILE_LOG(logINFO) << "Aufnahme wird auf " << Sekunden << "verlaengert " ; + LOG_INFO("Aufnahme wird auf " << Sekunden << "verlaengert ") updateClient(jobID,getCustomValue(jobID),0,Sekunden,getInfoText(jobID),startTime) ; addThreadMessage(jobID,std::string("104:" +convertIntToString(m_channelNum)+ ":2:") + convertStringToHex(fname)) ; } @@ -277,7 +278,7 @@ strTime->tm_hour, strTime->tm_min, strTime->tm_sec) ; - FILE_LOG(logDEBUG) << zeitString ; + LOG_DEBUG( zeitString) if (m_paramCount<2) { diff --git a/monitord/plugins/libmplugin_mysql.cpp b/monitord/plugins/libmplugin_mysql.cpp index 379bced..390e2e2 100644 --- a/monitord/plugins/libmplugin_mysql.cpp +++ b/monitord/plugins/libmplugin_mysql.cpp @@ -64,7 +64,7 @@ virtual void Show() { - FILE_LOG(logINFO) << "MonitorMySQLPlugin successfully loaded" ; + LOG_INFO("MonitorMySQLPlugin successfully loaded" ) } std::string escape_string(std::string text) @@ -79,7 +79,7 @@ virtual bool processResult(class ModuleResultBase *pRes) { - FILE_LOG(logDEBUG) << "mysql: processing Result..." ; + LOG_DEBUG("mysql: processing Result...") if (m_bConnected==false) { @@ -91,18 +91,18 @@ { usleep(100) ; pingcounter++ ; - FILE_LOG(logINFO) << "mysql connection lost ... trying reconnect" ; + LOG_INFO("mysql connection lost ... trying reconnect" ) } if (mysql_ping(&m_mysql)) { - FILE_LOG(logERROR) << " unable to reconnect to mysql database" ; + LOG_ERROR(" unable to reconnect to mysql database" ) return false ; } if (pingcounter>0) { - FILE_LOG(logINFO) << "mysql: connection re-established" ; + LOG_INFO("mysql: connection re-established" ) } // wenn wir latin1 einfuegen sollten wir das mysql auch mitteilen! @@ -158,7 +158,7 @@ } FILELog::ReportingLevel() = FILELog::FromString(logLevel); - FILE_LOG(logINFO) << "logging started"; + LOG_INFO("logging started") #endif if (ssl == 1 && ssl_cacert != "0" && ssl_cert != "0" && ssl_key != "0") @@ -169,7 +169,7 @@ ssl_cacert.c_str(), NULL, NULL); - FILE_LOG(logINFO) << "mySQL ssl support configured with key=" << ssl_key << " and cert=" << ssl_cert << " and cacert=" << ssl_cacert; + LOG_INFO("mySQL ssl support configured with key=" << ssl_key << " and cert=" << ssl_cert << " and cacert=" << ssl_cacert) } // Parameter parsen @@ -184,11 +184,11 @@ 0 // Options ) ==NULL) { - FILE_LOG(logERROR) << "Could not connect to database \"" << database << "\" on host " << hostname << " with username=\"" << username << "\"" ; + LOG_ERROR("Could not connect to database \"" << database << "\" on host " << hostname << " with username=\"" << username << "\"" ) m_bConnected=false ; } else { - FILE_LOG(logINFO) << "successfully connected to mysql database " << database << " on host " << hostname << " with username=\"" << username << "\"" ; + LOG_INFO("successfully connected to mysql database " << database << " on host " << hostname << " with username=\"" << username << "\"" ) m_bConnected=true ; } return m_bConnected ; @@ -228,8 +228,8 @@ std::string table=getNodeText(config,"table","status") ; std::string name, source, value ; - FILE_LOG(logDEBUG) << " reading mapping info " ; - FILE_LOG(logDEBUG) << "table="<< table ; + LOG_DEBUG("reading mapping info") + LOG_DEBUG("table=" << table) dbTable=table; FieldInfo *pFieldInfo ; @@ -247,7 +247,7 @@ if (name.empty()) ThrowMonitorException("MySQL Konfiguration: Kein Feldname vergeben ! ") ; if (value.empty()) ThrowMonitorException("MySQL Konfiguration: Kein Feldwert vergeben ! ") ; - FILE_LOG(logDEBUG) << "Feld: " << name << " / " << source << ":" << value ; + LOG_DEBUG("Feld: " << name << " / " << source << ":" << value) pFieldInfo=new FieldInfo ; pFieldInfo->value=value ; if (source=="mysql") @@ -276,7 +276,7 @@ fieldName= i->first ; pFieldInfo= i->second ; - FILE_LOG(logDEBUG) << "field:" << fieldName << " | value=" << pFieldInfo->value ; + LOG_DEBUG("field:" << fieldName << " | value=" << pFieldInfo->value) if (i!=mapping.begin()) { insertString+="," ; @@ -295,7 +295,7 @@ insertString+=") values (" ; insertString+=valueString + ")" ; - FILE_LOG(logDEBUG) << "Insertstring:" << insertString ; + LOG_DEBUG("Insertstring:" << insertString) return insertString ; } diff --git a/monitord/posix/MonitorAudioALSA.cpp b/monitord/posix/MonitorAudioALSA.cpp index 0cdee7f..9e1eb09 100644 --- a/monitord/posix/MonitorAudioALSA.cpp +++ b/monitord/posix/MonitorAudioALSA.cpp @@ -13,7 +13,7 @@ bool MonitorAudioALSA::Start(void *format) { if (InitDevice() < 0) { - FILE_LOG(logERROR) << "[ALSA] Error initializing PCM device " << pcm_name; + LOG_ERROR("[ALSA] Error initializing PCM device " << pcm_name) exit(10); } @@ -28,7 +28,7 @@ int MonitorAudioALSA::InitDevice() { if ((pcm_name.length() == 0) || (pcm_rate == 0)) { - FILE_LOG(logERROR) << "[ALSA] InitDevice Argument Error: pcm_name=" << pcm_name << " pcm_rate=" << pcm_rate ; + LOG_ERROR("[ALSA] InitDevice Argument Error: pcm_name=" << pcm_name << " pcm_rate=" << pcm_rate ) return -1; } @@ -53,13 +53,13 @@ /* been completely processed by the soundcard. */ ret = snd_pcm_open(&pcm_handle, pcm_name.c_str(), pcm_stream, 0); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error opening PCM device " << pcm_name << " ret:" << ret << snd_strerror(ret); + LOG_ERROR("[ALSA] Error opening PCM device " << pcm_name << " ret:" << ret << snd_strerror(ret)) return -1; } /* Init hwparams with full configuration space */ ret = snd_pcm_hw_params_any(pcm_handle, hwparams); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Can not configure this PCM device " << pcm_name << ". " << ret << "(" << snd_strerror(ret) << ")" ; + LOG_ERROR("[ALSA] Can not configure this PCM device " << pcm_name << ". " << ret << "(" << snd_strerror(ret) << ")" ) return -1; } /* Set access type. This can be either */ @@ -70,20 +70,20 @@ /* of this introduction. */ ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_NONINTERLEAVED); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting access " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting access " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") return -1; } /* Set number of channels */ ret = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, 2); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting channels " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting channels " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") return -1; } /* Set sample rate. If the exact rate is not supported */ /* by the hardware, use nearest possible rate. */ ret = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &pcm_rate, &direction); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting rate " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting rate " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") return -1; } /* Set sample format */ @@ -91,26 +91,26 @@ ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, SND_PCM_FORMAT_FLOAT_LE); //ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, SND_PCM_FORMAT_S16_LE); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting format " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting format " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") return -1; } /* Set buffer size */ ret = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &pcm_buffer_size); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting buffer size " << pcm_name << ". " << (int)pcm_buffer_size << " - " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting buffer size " << pcm_name << ". " << (int)pcm_buffer_size << " - " << ret <<"(" << snd_strerror(ret)<<")") } /* Set number of periods. Periods used to be called fragments. */ ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &periods, &direction); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting periods " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting periods " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") } - FILE_LOG(logINFO) << "[ALSA] Using pcm_buffer_size=" <<(int)pcm_buffer_size << " periods=" << periods ; + LOG_INFO("[ALSA] Using pcm_buffer_size=" <<(int)pcm_buffer_size << " periods=" << periods ) /* Apply HW parameter settings to */ /* PCM device and prepare device */ ret = snd_pcm_hw_params(pcm_handle, hwparams); if (ret < 0) { - FILE_LOG(logERROR) << "[ALSA] Error setting HW params " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")"; + LOG_ERROR("[ALSA] Error setting HW params " << pcm_name << ". " << ret <<"(" << snd_strerror(ret)<<")") return -1; } @@ -136,15 +136,15 @@ } else if (num_samples == -EPIPE) { int err = snd_pcm_prepare(pcm_handle); if (err < 0) { - FILE_LOG(logERROR) << "[ALSA] Can't recovery from underrun, prepare failed: " << snd_strerror(err); + LOG_ERROR("[ALSA] Can't recovery from underrun, prepare failed: " << snd_strerror(err)) } } else if (num_samples < 0) { - FILE_LOG(logERROR) << "[ALSA] Read error " << num_samples << "(" << snd_strerror(num_samples) << ")" ; + LOG_ERROR( "[ALSA] Read error " << num_samples << "(" << snd_strerror(num_samples) << ")" ) /* Schliessen des Sounddevices und neustarten */ CloseDevice(); sleep(1); if (InitDevice() < 0) { - FILE_LOG(logERROR) << "[ALSA] Error initializing PCM device " << pcm_name ; + LOG_ERROR("[ALSA] Error initializing PCM device " << pcm_name ) } } } diff --git a/monitord/posix/MonitorAudioOSS.cpp b/monitord/posix/MonitorAudioOSS.cpp index ce3d81c..6e7946a 100644 --- a/monitord/posix/MonitorAudioOSS.cpp +++ b/monitord/posix/MonitorAudioOSS.cpp @@ -23,7 +23,7 @@ bool MonitorAudioOSS::Start(void *format) { if (InitDevice() < 0) { - FILE_LOG(logERROR) << "Error initializing PCM device " << pcm_name ; + LOG_ERROR("Error initializing PCM device " << pcm_name ) exit(10); } @@ -33,7 +33,7 @@ } void MonitorAudioOSS::Stop() { - FILE_LOG(logERROR) << "stopping " << pcm_name ; + LOG_ERROR("stopping " << pcm_name ) run = false; } @@ -45,25 +45,24 @@ } if ((dev_handle = open(pcm_name.c_str(), O_RDONLY)) < 0) { - FILE_LOG(logERROR) << "open" ; + LOG_ERROR("open" ) return -1; } sndparam = AFMT_S16_LE; /* we want 16 bits/sample signed */ /* little endian; works only on little endian systems! */ if (ioctl(dev_handle, SNDCTL_DSP_SETFMT, &sndparam) == -1) { - FILE_LOG(logERROR) << "ioctl: SNDCTL_DSP_SETFMT"; + LOG_ERROR("ioctl: SNDCTL_DSP_SETFMT") return -1; } sndparam = 1; /* 2 Kanäle */ if (ioctl(dev_handle, SNDCTL_DSP_STEREO, &sndparam) == -1) { - FILE_LOG(logERROR) << ("ioctl: SNDCTL_DSP_STEREO"); + LOG_ERROR(("ioctl: SNDCTL_DSP_STEREO")) return -1; } if (sndparam != 1) { /* Monovariante? */ - FILE_LOG(logERROR) << "soundif: Error, cannot set the channel " << - "number to 2"; + LOG_ERROR("soundif: Error, cannot set the channel number to 2") return -1; } @@ -81,12 +80,12 @@ short *temp_buffer; float *left, *right; if ((temp_buffer = (short*) malloc(audio_buffer->SampleLen * sizeof (short) * 2)) == NULL) { - FILE_LOG(logERROR) << "cannot allocate temporary audio buffer"; + LOG_ERROR("cannot allocate temporary audio buffer") exit (-1); } JThread::ThreadStarted(); - FILE_LOG(logINFO) << "AudioThread " << pcm_name << " is running" ; + LOG_INFO("AudioThread " << pcm_name << " is running" ) while(run) { bytes = read(dev_handle, temp_buffer, audio_buffer->SampleLen * sizeof (short) * 2); @@ -108,12 +107,12 @@ CloseDevice(); sleep(1); if (InitDevice() < 0) { - FILE_LOG(logERROR) << "Error initializing PCM device "<< pcm_name ; + LOG_ERROR("Error initializing PCM device "<< pcm_name ) } } } - FILE_LOG(logINFO) << "AudioThread " << pcm_name << " has stopped" ; + LOG_INFO("AudioThread " << pcm_name << " has stopped" ) free(temp_buffer); return NULL; diff --git a/monitord/win32/MonitorAudioWin32.cpp b/monitord/win32/MonitorAudioWin32.cpp index e7fb68f..a51e898 100644 --- a/monitord/win32/MonitorAudioWin32.cpp +++ b/monitord/win32/MonitorAudioWin32.cpp @@ -36,8 +36,7 @@ int MonitorAudioWin32::InitDevice() { if ((pcm_name.length() == 0) || (pcm_rate == 0)) { - FILE_LOG(logERROR) << "[WINMM] InitDevice Argument Error: pcm_name=" - << pcm_name << ", pcm_rate=" << pcm_rate ; + LOG_ERROR("[WINMM] InitDevice Argument Error: pcm_name=" << pcm_name << ", pcm_rate=" << pcm_rate) return -1; } @@ -62,7 +61,7 @@ if (deviceName.substr(0,devString.size())==devString) { nDevId=convertToInt(deviceName.substr(devString.size())); - FILE_LOG(logINFO) << "using windows device #" << nDevId ; + LOG_INFO("using windows device #" << nDevId ) } if ((nDevId<0)) { @@ -73,7 +72,7 @@ rc = waveInGetDevCaps(nDevId, &wic, sizeof(wic)); if (rc == MMSYSERR_NOERROR) { - FILE_LOG(logINFO) << "starting wavein for sounddevice: \"" << wic.szPname << "\"" ; + LOG_INFO("starting wavein for sounddevice: \"" << wic.szPname << "\"" ) wfx.nChannels = 2; // stereo wfx.nSamplesPerSec = 22050; // 22.05 kHz (22.05 * 1000) wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -119,7 +118,7 @@ } int MonitorAudioWin32::CloseDevice() { - FILE_LOG(logINFO) << "Closing sound device..." ; + LOG_INFO("Closing sound device..." ) int i=0 ; // waveInReset Stops the device and sets all the pending buffers to zero. if (hwi != NULL) { @@ -151,7 +150,7 @@ } } } - FILE_LOG(logINFO) << "sound device closed" ; + LOG_INFO("sound device closed" ) return 0; } @@ -209,7 +208,7 @@ rc=InitDevice() ; if ( rc < 0) { - FILE_LOG(logERROR) << "[WINMM] Error initializing PCM device " << pcm_name; + LOG_ERROR("[WINMM] Error initializing PCM device " << pcm_name) return NULL ; } @@ -253,11 +252,11 @@ } } - FILE_LOG(logINFO) << "stopping soundcard" ; + LOG_INFO("stopping soundcard" ) /* stop waveIn */ waveInStop(hwi); Sleep(1000) ; - FILE_LOG(logINFO) << "soundcard stopped" ; + LOG_INFO("soundcard stopped" ) return NULL; } @@ -267,7 +266,7 @@ if (result != MMSYSERR_NOERROR) { char errorbuffer[100]; waveInGetErrorText (result, errorbuffer, 100); - FILE_LOG(logERROR) << "[WINMM] Error " << result << ":" << errorbuffer << " (" << addstr << ")" ; + LOG_ERROR("[WINMM] Error " << result << ":" << errorbuffer << " (" << addstr << ")" ) } } diff --git a/monitord/win32/MonitorService.cpp b/monitord/win32/MonitorService.cpp index f1e45d5..2ae4ec1 100644 --- a/monitord/win32/MonitorService.cpp +++ b/monitord/win32/MonitorService.cpp @@ -95,7 +95,7 @@ // process terminate. The SCM will diligently log this event. // - FILE_LOG(logINFO) << "ServiceMain Startet" ; + LOG_INFO("ServiceMain Startet" ) assert (0 != m_service); if (1 != argc || 0 == argv || 0 == argv[0]) @@ -131,7 +131,7 @@ void WINAPI MonitorService::Handler(DWORD control) { #ifdef _DEBUG - FILE_LOG(logINFO) << "Handler: empfangen:" << control << ".." << m_service ; + LOG_INFO("Handler: empfangen:" << control << ".." << m_service ) #endif //assert (0 == m_service); switch (control) @@ -153,7 +153,7 @@ case SERVICE_CONTROL_SHUTDOWN : case SERVICE_CONTROL_STOP : { - FILE_LOG(logINFO) << "ServiceMain stopping ... " ; + LOG_INFO( "ServiceMain stopping ... " ) m_service->Stop(); break; } @@ -169,7 +169,7 @@ void MonitorService::UpdateState(DWORD state, HRESULT errorCode) { #ifdef _DEBUG - FILE_LOG(logDEBUG) << "Updatestatus ..." ; + LOG_DEBUG("Updatestatus ..." ) #endif //assert (0 != m_service); @@ -195,7 +195,7 @@ // FIXME AtlThrowLastWin32(); } - FILE_LOG(logDEBUG) << "Updatestatus ... done" ; + LOG_DEBUG("Updatestatus ... done" ) }