From fca970085f24a2e71f8cc28dd068d74669c59596 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 3 Sep 2021 18:37:59 +0100 Subject: [PATCH] Log conversion --- control.cc | 172 ++++++++++++++++++++-------------------- control.h | 4 +- input.cc | 10 ++- inputman.cc | 24 +++--- inputudp.cc | 28 ++++--- inputudp.h | 4 +- log.h | 17 ++-- main.cc | 2 +- tcp.cc | 34 ++++---- tcp.h | 4 +- teletextdecodervbiebu.h | 8 +- timers.cc | 28 ++++--- timers.h | 4 +- udp4.cc | 6 +- udp6.cc | 10 ++- vdpc.cc | 50 ++++++------ vdr.cc | 122 ++++++++++++++-------------- vdr.h | 2 +- 18 files changed, 275 insertions(+), 254 deletions(-) diff --git a/control.cc b/control.cc index f421d1f..adbb67d 100644 --- a/control.cc +++ b/control.cc @@ -55,7 +55,7 @@ #include "vinfo.h" #include "boxx.h" #include "boxstack.h" -#include "oldlog.h" +#include "log.h" #include "sleeptimer.h" #include "wjpeg.h" #include "osdvector.h" @@ -83,6 +83,8 @@ #include "control.h" +static const char* TAG = "Control"; + Control* Control::instance = NULL; Control::Control() @@ -106,7 +108,7 @@ bool Control::init(bool tcrashed) { if (initted) return false; crashed = tcrashed; - logger = Log::getInstance(); + logger = LogNT::getInstance(); SkinFactory::InitSkin(0); @@ -143,24 +145,24 @@ bool Control::init(bool tcrashed) } catch (int e) { - if (e == 10) logger->log("Control", Log::EMERG, "LED module failed to create"); - else if (e == 11) logger->log("Control", Log::EMERG, "LED module failed to initialise"); - else if (e == 20) logger->log("Control", Log::EMERG, "Timers module failed to create"); - else if (e == 21) logger->log("Control", Log::EMERG, "Timers module failed to initialise"); - else if (e == 30) logger->log("Control", Log::EMERG, "Video module failed to create"); - else if (e == 31) logger->log("Control", Log::EMERG, "Video module failed to initialise"); - else if (e == 40) logger->log("Control", Log::EMERG, "Audio module failed to create"); - else if (e == 41) logger->log("Control", Log::EMERG, "Audio module failed to initialise"); - else if (e == 50) logger->log("Control", Log::EMERG, "OSD module failed to create"); - else if (e == 51) logger->log("Control", Log::EMERG, "OSD module failed to initialise"); - else if (e == 60) logger->log("Control", Log::EMERG, "VDR module failed to create"); - else if (e == 61) logger->log("Control", Log::EMERG, "VDR module failed to initialise"); - else if (e == 70) logger->log("Control", Log::EMERG, "BoxStack module failed to create"); - else if (e == 71) logger->log("Control", Log::EMERG, "BoxStack module failed to initialise"); - else if (e == 80) logger->log("Control", Log::EMERG, "SleepTimer module failed to create"); - else if (e == 90) logger->log("Control", Log::EMERG, "WOL module failed to create"); - else if (e == 100) logger->log("Control", Log::EMERG, "InputMan module failed to create"); - else if (e == 101) logger->log("Control", Log::EMERG, "InputMan module failed to initialise"); + if (e == 10) logger->crit(TAG, "LED module failed to create"); + else if (e == 11) logger->crit(TAG, "LED module failed to initialise"); + else if (e == 20) logger->crit(TAG, "Timers module failed to create"); + else if (e == 21) logger->crit(TAG, "Timers module failed to initialise"); + else if (e == 30) logger->crit(TAG, "Video module failed to create"); + else if (e == 31) logger->crit(TAG, "Video module failed to initialise"); + else if (e == 40) logger->crit(TAG, "Audio module failed to create"); + else if (e == 41) logger->crit(TAG, "Audio module failed to initialise"); + else if (e == 50) logger->crit(TAG, "OSD module failed to create"); + else if (e == 51) logger->crit(TAG, "OSD module failed to initialise"); + else if (e == 60) logger->crit(TAG, "VDR module failed to create"); + else if (e == 61) logger->crit(TAG, "VDR module failed to initialise"); + else if (e == 70) logger->crit(TAG, "BoxStack module failed to create"); + else if (e == 71) logger->crit(TAG, "BoxStack module failed to initialise"); + else if (e == 80) logger->crit(TAG, "SleepTimer module failed to create"); + else if (e == 90) logger->crit(TAG, "WOL module failed to create"); + else if (e == 100) logger->crit(TAG, "InputMan module failed to create"); + else if (e == 101) logger->crit(TAG, "InputMan module failed to initialise"); switch(e) { @@ -247,20 +249,20 @@ void Control::shutdown() inputMan->shutdown(); delete inputMan; inputMan = NULL; - logger->log("Control", Log::NOTICE, "InputMan module shut down"); + logger->info(TAG, "InputMan module shut down"); } if (wol) { delete wol; - logger->log("Control", Log::NOTICE, "WOL module shut down"); + logger->info(TAG, "WOL module shut down"); } if (sleepTimer) { delete sleepTimer; sleepTimer = NULL; - logger->log("Control", Log::NOTICE, "SleepTimer module shut down"); + logger->info(TAG, "SleepTimer module shut down"); } if (boxstack) @@ -268,7 +270,7 @@ void Control::shutdown() boxstack->shutdown(); delete boxstack; boxstack = NULL; - logger->log("Control", Log::NOTICE, "BoxStack module shut down"); + logger->info(TAG, "BoxStack module shut down"); } if (vdr) @@ -276,7 +278,7 @@ void Control::shutdown() vdr->shutdown(); delete vdr; vdr = NULL; - logger->log("Control", Log::NOTICE, "VDR module shut down"); + logger->info(TAG, "VDR module shut down"); } if (osd) @@ -284,7 +286,7 @@ void Control::shutdown() osd->shutdown(); delete osd; osd = NULL; - logger->log("Control", Log::NOTICE, "OSD module shut down"); + logger->info(TAG, "OSD module shut down"); } if (audio) @@ -292,7 +294,7 @@ void Control::shutdown() audio->shutdown(); delete audio; audio = NULL; - logger->log("Control", Log::NOTICE, "Audio module shut down"); + logger->info(TAG, "Audio module shut down"); } if (video) @@ -300,7 +302,7 @@ void Control::shutdown() video->shutdown(); delete video; video = NULL; - logger->log("Control", Log::NOTICE, "Video module shut down"); + logger->info(TAG, "Video module shut down"); } if (timers) @@ -308,7 +310,7 @@ void Control::shutdown() timers->shutdown(); delete timers; timers = NULL; - logger->log("Control", Log::NOTICE, "Timers module shut down"); + logger->info(TAG, "Timers module shut down"); } if (led) @@ -316,13 +318,13 @@ void Control::shutdown() led->shutdown(); delete led; led = NULL; - logger->log("Control", Log::NOTICE, "LED module shut down"); + logger->info(TAG, "LED module shut down"); } } void Control::stop() { - logger->log("Control", Log::NOTICE, "Request stop"); + logger->info(TAG, "Request stop"); Message* m = new Message(); // break master loop m->message = Message::SHUTDOWN; @@ -352,7 +354,7 @@ void Control::doWallpaper() if (video->getFormat() == Video::PAL) { - logger->log("Control", Log::DEBUG, "PAL wallpaper selected"); + logger->debug(TAG, "PAL wallpaper selected"); #ifndef _MIPS_ARCH wallpaper_pict->init("/wallpaperPAL.jpg"); #else @@ -361,7 +363,7 @@ void Control::doWallpaper() } else { - logger->log("Control", Log::DEBUG, "NTSC wallpaper selected"); + logger->debug(TAG, "NTSC wallpaper selected"); wallpaper_pict->init("/wallpaperNTSC.jpg"); } @@ -412,7 +414,7 @@ void Control::run() while(irun) { messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); }); - logger->log("Control", Log::DEBUG, "woke"); + logger->debug(TAG, "woke"); if (!irun) break; @@ -443,7 +445,7 @@ void Control::processMessage(Message* m) // themselves as receivers to avoid the calling-a-deleted-object problem // then only deliver/register/unregister would have to be protected - logger->log("Control", Log::DEBUG, "processing message %i", m->message); + logger->debug(TAG, "processing message {}", m->message); if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined? @@ -472,7 +474,7 @@ void Control::processMessage(Message* m) } case Message::SCREENSHOT: { - logger->log("Osd", Log::NOTICE, "Screenshot Message arrived"); + logger->info(TAG, "Screenshot Message arrived"); Osd::getInstance()->screenShot("out.jpg"); break; } @@ -483,7 +485,7 @@ void Control::processMessage(Message* m) } case Message::INPUT_EVENT: { - logger->log("Control", Log::NOTICE, "INPUT_EVENT %i", m->parameter); + logger->info(TAG, "INPUT_EVENT {}", m->parameter); handleCommand(m->parameter); break; @@ -542,7 +544,7 @@ void Control::processMessage(Message* m) This could all be done using the existing big control mutex to keep it simple */ - logger->log("Control", Log::DEBUG, "Sending message to boxstack"); + logger->debug(TAG, "Sending message to boxstack"); boxstack->processMessage(m); } } @@ -616,7 +618,7 @@ void Control::handleCommand(int button) } case Input::GO: { - logger->log("Control", Log::DEBUG, "Handling sleeptimer go"); + logger->debug(TAG, "Handling sleeptimer go"); sleepTimer->go(); return; } @@ -689,11 +691,11 @@ void Control::doFromTheTop(bool which) { if (connLost) { - logger->log("Control", Log::NOTICE, "Connection lost dialog already present"); + logger->info(TAG, "Connection lost dialog already present"); return; } - logger->log("Control", Log::NOTICE, "Doing connection lost dialog"); + logger->info(TAG, "Doing connection lost dialog"); connLost = new VInfo(); connLost->setSize(360, 200); connLost->createBuffer(); @@ -756,7 +758,7 @@ void Control::doReboot() logger->unsetExternLogger(); VDR::getInstance()->disconnect(); // just kill it... - logger->log("Control", Log::NOTICE, "Reboot"); + logger->info(TAG, "Reboot"); #ifndef WIN32 #ifndef VOMP_HAS_EXIT // some plattforms, want a proper deinitialisation of their hardware before reboot @@ -854,7 +856,7 @@ void Control::doJustConnected(VConnect* vconnect) { I18n::initialize(); if (!VDR::getInstance()->isConnected()) { connectionLost(); return; } - logger->log("Control", Log::INFO, "Entering doJustConnected"); + logger->info(TAG, "Entering doJustConnected"); boxstack->remove(vconnect); @@ -878,13 +880,13 @@ void Control::doJustConnected(VConnect* vconnect) config = vdr->configLoad("Advanced", "Network logging"); if (config && !STRCASECMP(config, "On")) { - logger->log("Control", Log::INFO, "Turning on network logging"); + logger->info(TAG, "Turning on network logging"); logger->setExternLogger(vdr); } else { logger->unsetExternLogger(); - logger->log("Control", Log::INFO, "Turned off network logging"); + logger->info(TAG, "Turned off network logging"); } if (config) delete[] config; @@ -922,7 +924,7 @@ void Control::doJustConnected(VConnect* vconnect) config = vdr->configLoad("General", "Override Video Format"); if (config) { - logger->log("Control", Log::DEBUG, "Override Video Format is present"); + logger->debug(TAG, "Override Video Format is present"); if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL)) || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC)) @@ -948,20 +950,20 @@ void Control::doJustConnected(VConnect* vconnect) // Get video and osd back up with the new mode if (!strcmp(config, "PAL")) { - logger->log("Control", Log::DEBUG, "Switching to PAL"); + logger->debug(TAG, "Switching to PAL"); video->init(Video::PAL); } else if (!strcmp(config, "NTSC")) { - logger->log("Control", Log::DEBUG, "Switching to NTSC"); + logger->debug(TAG, "Switching to NTSC"); video->init(Video::NTSC); } else if (!strcmp(config, "PAL_M")) { - logger->log("Control", Log::DEBUG, "Switching to PAL_M"); + logger->debug(TAG, "Switching to PAL_M"); video->init(Video::PAL_M); } else if (!strcmp(config, "NTSC_J")) { - logger->log("Control", Log::DEBUG, "Switching to NTSC_J"); + logger->debug(TAG, "Switching to NTSC_J"); video->init(Video::NTSC_J); } delete[] config; @@ -990,12 +992,12 @@ void Control::doJustConnected(VConnect* vconnect) } else { - logger->log("Control", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'"); + logger->debug(TAG, "Already in requested mode, or request was not 'PAL' or 'NTSC'"); } } else { - logger->log("Control", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!"); + logger->debug(TAG, "Phew, no dangerous on-the-fly mode switching to do!"); } // Power off if first boot and config says so @@ -1003,7 +1005,7 @@ void Control::doJustConnected(VConnect* vconnect) { firstBoot = false; - logger->log("Control", Log::DEBUG, "Load power after boot"); + logger->debug(TAG, "Load power after boot"); config = vdr->configLoad("General", "Power After Boot"); @@ -1011,11 +1013,11 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "On")) { - logger->log("Control", Log::INFO, "Config says Power After Boot = On"); + logger->info(TAG, "Config says Power After Boot = On"); } else if (!STRCASECMP(config, "Off")) { - logger->log("Control", Log::INFO, "Config says Power After Boot = Off"); + logger->info(TAG, "Config says Power After Boot = Off"); doStandby(); delete[] config; return; // quit here @@ -1027,34 +1029,34 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(lastPowerState, "On")) { - logger->log("Control", Log::INFO, "Config says Last Power State = On"); + logger->info(TAG, "Config says Last Power State = On"); } else if (!STRCASECMP(lastPowerState, "Off")) { - logger->log("Control", Log::INFO, "Config says Last Power State = Off"); + logger->info(TAG, "Config says Last Power State = Off"); doStandby(); delete[] config; return; // quit here } else { - logger->log("Control", Log::INFO, "Config General/Last Power State not understood"); + logger->info(TAG, "Config General/Last Power State not understood"); } } else { - logger->log("Control", Log::INFO, "Config General/Last Power State not found"); + logger->info(TAG, "Config General/Last Power State not found"); } } else { - logger->log("Control", Log::INFO, "Config/Power After Boot not understood"); + logger->info(TAG, "Config/Power After Boot not understood"); } delete[] config; } else { - logger->log("Control", Log::INFO, "Config General/Power After Boot not found"); + logger->info(TAG, "Config General/Power After Boot not found"); } } @@ -1067,27 +1069,27 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "S-Video")) { - logger->log("Control", Log::INFO, "Switching to S-Video as Connection=%s", config); + logger->info(TAG, "Switching to S-Video as Connection=%s", config); video->setConnection(Video::SVIDEO); } else if (!STRCASECMP(config, "HDMI")) { - logger->log("Control", Log::INFO, "Switching to HDMI as Connection=%s", config); + logger->info(TAG, "Switching to HDMI as Connection=%s", config); video->setConnection(Video::HDMI); } else if (!STRCASECMP(config, "HDMI3D")) { - logger->log("Control", Log::INFO, "Switching to HDMI3D as Connection=%s", config); + logger->info(TAG, "Switching to HDMI3D as Connection=%s", config); video->setConnection(Video::HDMI3D); } else { - logger->log("Control", Log::INFO, "Switching to RGB/Composite as Connection=%s", config); + logger->info(TAG, "Switching to RGB/Composite as Connection=%s", config); video->setConnection(Video::COMPOSITERGB); } delete[] config; } else { - logger->log("Control", Log::INFO, "Config TV/S-Video not found"); + logger->info(TAG, "Config TV/S-Video not found"); } // Set to shutdown VDR if config says @@ -1097,18 +1099,18 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "On")) { - logger->log("Control", Log::INFO, "Shutdown VDR when shutting down vomp"); + logger->info(TAG, "Shutdown VDR when shutting down vomp"); vdr->setVDRShutdown(true); } else if (!STRCASECMP(config, "Off")) { - logger->log("Control", Log::INFO, "Shutdown only vomp"); + logger->info(TAG, "Shutdown only vomp"); vdr->setVDRShutdown(false); } } else { - logger->log("Control", Log::INFO, "Default shutdown only vomp"); + logger->info(TAG, "Default shutdown only vomp"); vdr->setVDRShutdown(false); // Default } @@ -1119,19 +1121,19 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "16:9")) { - logger->log("Control", Log::INFO, "/// Switching to TV aspect 16:9"); + logger->info(TAG, "/// Switching to TV aspect 16:9"); video->setTVsize(Video::ASPECT16X9); } else { - logger->log("Control", Log::INFO, "/// Switching to TV aspect 4:3"); + logger->info(TAG, "/// Switching to TV aspect 4:3"); video->setTVsize(Video::ASPECT4X3); } delete[] config; } else { - logger->log("Control", Log::INFO, "Config TV/Aspect type not found, going 4:3"); + logger->info(TAG, "Config TV/Aspect type not found, going 4:3"); video->setTVsize(Video::ASPECT4X3); } @@ -1140,12 +1142,12 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "Letterbox")) { - logger->log("Control", Log::INFO, "Setting letterbox mode"); + logger->info(TAG, "Setting letterbox mode"); video->setMode(Video::LETTERBOX); } else { - logger->log("Control", Log::INFO, "Setting chop-sides mode"); + logger->info(TAG, "Setting chop-sides mode"); video->setMode(Video::NORMAL); } delete[] config; @@ -1153,10 +1155,10 @@ void Control::doJustConnected(VConnect* vconnect) else { #ifdef __ANDROID__ - logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode"); + logger->info(TAG, "Config TV/Widemode not found, Setting letterbox mode"); video->setMode(Video::LETTERBOX); #else - logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode"); + logger->info(TAG, "Config TV/Widemode not found, Setting chop-sides mode"); video->setMode(Video::NORMAL); #endif } @@ -1167,12 +1169,12 @@ void Control::doJustConnected(VConnect* vconnect) size_t newTCPsize = atoi(config); delete[] config; - logger->log("Control", Log::INFO, "Setting TCP window size %i", newTCPsize); + logger->info(TAG, "Setting TCP window size %i", newTCPsize); vdr->setReceiveWindow(newTCPsize); } else { - logger->log("Control", Log::INFO, "TCP window size not found, setting 2048"); + logger->info(TAG, "TCP window size not found, setting 2048"); if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default } @@ -1180,7 +1182,7 @@ void Control::doJustConnected(VConnect* vconnect) if (config) { Osd::getInstance()->setFont(config); - logger->log("Control", Log::INFO, "Setting Font to %s", config); + logger->info(TAG, "Setting Font to %s", config); delete[] config; } @@ -1195,19 +1197,19 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "Advanced")) { - logger->log("Control", Log::INFO, "Switching to Advanced menu"); + logger->info(TAG, "Switching to Advanced menu"); advMenus = true; } else { - logger->log("Control", Log::INFO, "Switching to Classic menu"); + logger->info(TAG, "Switching to Classic menu"); advMenus = false; } delete[] config; } else { - logger->log("Control", Log::INFO, "Config General/menu type not found"); + logger->info(TAG, "Config General/menu type not found"); advMenus = true; } #endif @@ -1217,12 +1219,12 @@ void Control::doJustConnected(VConnect* vconnect) { if (!STRCASECMP(config, "Yes")) { - logger->log("Control", Log::INFO, "Config says disable WOL"); + logger->info(TAG, "Config says disable WOL"); Wol::getInstance()->setEnabled(false); } else { - logger->log("Control", Log::INFO, "Config says enable WOL"); + logger->info(TAG, "Config says enable WOL"); Wol::getInstance()->setEnabled(true); } @@ -1230,7 +1232,7 @@ void Control::doJustConnected(VConnect* vconnect) } else { - logger->log("Control", Log::INFO, "By default, enable WOL"); + logger->info(TAG, "By default, enable WOL"); Wol::getInstance()->setEnabled(true); } /* device dependend config */ diff --git a/control.h b/control.h index 6524cee..4c6a7bd 100644 --- a/control.h +++ b/control.h @@ -32,7 +32,7 @@ class Message; class InputMan; class Boxx; class BoxStack; -class Log; +class LogNT; class VInfo; class WJpeg; class SleepTimer; @@ -101,7 +101,7 @@ class Control : public MessageQueue static Control* instance; - Log* logger; + LogNT* logger; bool initted{}; bool irun{}; diff --git a/input.cc b/input.cc index 423c53f..dcc4413 100644 --- a/input.cc +++ b/input.cc @@ -19,7 +19,7 @@ #include "wremoteconfig.h" #include "i18n.h" -#include "oldlog.h" +#include "log.h" #include "vdr.h" #include "wtabbar.h" #include "message.h" @@ -27,6 +27,8 @@ #include "inputman.h" #include "input.h" +static const char* TAG = "Input"; + void Input::ResetToDefault() { translist.clear(); @@ -79,7 +81,7 @@ void Input::LoadKeysConfig(VDR *vdr,const char *cfg) { ULONG number=0; if (sscanf(cfg,"%ld",&number) != 1) return; - Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys num keys %d",number); + LogNT::getInstance()->info(TAG, "Config Input/Remote keys num keys {}", number); char keybuf[1024]; for (ULONG i = 0; i < number; i++) { sprintf(keybuf, "RemoteKey%lu", i); @@ -125,13 +127,13 @@ bool Input::loadOptionsFromServer(VDR* vdr) if (config) { - Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys load"); + LogNT::getInstance()->info(TAG, "Config Input/Remote keys load"); LoadKeysConfig(vdr,config); delete[] config; } else { - Log::getInstance()->log("Input", Log::INFO, "Config Input/Remote keys not found"); + LogNT::getInstance()->info(TAG, "Config Input/Remote keys not found"); InitHWCListwithDefaults(); } return true; diff --git a/inputman.cc b/inputman.cc index d5cc4eb..6e52aac 100644 --- a/inputman.cc +++ b/inputman.cc @@ -18,7 +18,7 @@ */ #include "config.h" -#include "oldlog.h" +#include "log.h" #include "wremoteconfig.h" #include "wtabbar.h" #ifdef VOMP_PLATFORM_RASPBERRY @@ -35,6 +35,8 @@ #include "inputman.h" +static const char* TAG = "InputMan"; + InputMan* InputMan::instance = NULL; InputMan::InputMan() @@ -113,7 +115,7 @@ bool InputMan::init() if (!oneOK) { - Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module"); + LogNT::getInstance()->crit(TAG, "InputMan could not init any input module"); return false; } @@ -123,7 +125,7 @@ bool InputMan::init() bool InputMan::start() { - Log::getInstance()->log("InputMan", Log::DEBUG, "Start"); + LogNT::getInstance()->debug(TAG, "Start"); bool oneOK{}; @@ -160,14 +162,14 @@ bool InputMan::start() } if (!oneOK) - Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not start any input module"); + LogNT::getInstance()->crit(TAG, "InputMan could not start any input module"); return oneOK; } void InputMan::stop() { - Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called"); + LogNT::getInstance()->debug(TAG, "Stop called"); #ifdef VOMP_PLATFORM_RASPBERRY if (inputLinux) inputLinux->stop(); @@ -178,13 +180,13 @@ void InputMan::stop() void InputMan::shutdown() { - Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start"); + LogNT::getInstance()->debug(TAG, "Shutdown start"); #ifdef VOMP_PLATFORM_RASPBERRY if (inputLinux) { - Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux"); + LogNT::getInstance()->debug(TAG, "Shutdown start - Linux"); inputLinux->stop(); inputLinux->shutdown(); delete inputLinux; @@ -193,7 +195,7 @@ void InputMan::shutdown() if (inputCEC) { - Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - CEC"); + LogNT::getInstance()->debug(TAG, "Shutdown start - CEC"); inputCEC->shutdown(); delete inputCEC; inputCEC = NULL; @@ -203,7 +205,7 @@ void InputMan::shutdown() if (inputUDP) { - Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP"); + LogNT::getInstance()->debug(TAG, "Shutdown start - UDP"); inputUDP->stop(); inputUDP->shutdown(); delete inputUDP; @@ -212,7 +214,7 @@ void InputMan::shutdown() if (inputLirc) { - Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - LIRC"); + LogNT::getInstance()->debug(TAG, "Shutdown start - LIRC"); inputLirc->stop(); inputLirc->shutdown(); delete inputLirc; @@ -460,7 +462,7 @@ const UCHAR InputMan::getVompKeyNumber(const char* vompKeyName) else if (!strcmp(vompKeyName, "PLAYPAUSE")) return Input::PLAYPAUSE; else if (!strcmp(vompKeyName, "POWERON")) return Input::POWERON; else if (!strcmp(vompKeyName, "POWEROFF")) return Input::POWEROFF; - else return NULL; + else return Input::NA_UNKNOWN; } std::string InputMan::getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey) diff --git a/inputudp.cc b/inputudp.cc index 6a37b29..35ea47d 100644 --- a/inputudp.cc +++ b/inputudp.cc @@ -22,22 +22,24 @@ #include #endif -#include "oldlog.h" +#include "log.h" #include "inputudp.h" +static const char* TAG = "InputUDP"; + const char* InputUDP::myModName = "InputUDP"; bool InputUDP::init() { if (initted) return false; initted = true; - log = Log::getInstance(); - log->log("InputUDP", Log::DEBUG, "Starting InputUDP command server"); + log = LogNT::getInstance(); + log->debug(TAG, "Starting InputUDP command server"); if (!udp4.init(2000)) { - log->log("InputUDP", Log::DEBUG, "UDP4 init error"); + log->debug(TAG, "UDP4 init error"); initted = false; return false; } @@ -46,11 +48,11 @@ bool InputUDP::init() quitPipe = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (quitPipe == INVALID_SOCKET) { - Log::getInstance()->log("InputUDP", Log::ERR, "Win32 socket fail"); + log->error(TAG, "Win32 socket fail"); #else if (pipe2(pfds, O_NONBLOCK) == -1) { - Log::getInstance()->log("InputUDP", Log::ERR, "pipe2() fail"); + log->error(TAG, "pipe2() fail"); #endif udp4.shutdown(); initted = false; @@ -87,7 +89,7 @@ bool InputUDP::start() }); threadStartProtect.unlock(); - log->log("InputUDP", Log::DEBUG, "InputUDP command server started"); + log->debug(TAG, "InputUDP command server started"); return true; } @@ -100,7 +102,7 @@ void InputUDP::stop() if (listenThread.joinable()) { #ifdef WIN32 - Log::getInstance()->log("InputUDP", Log::DEBUG, "Calling CLOSESOCKET on WIN32 quitPipe"); + log->debug(TAG, "Calling CLOSESOCKET on WIN32 quitPipe"); CLOSESOCKET(quitPipe); #else @@ -120,7 +122,7 @@ void InputUDP::listenLoop() #else retval = udp4.waitforMessage(3, pfds[0]); #endif - Log::getInstance()->log("InputUDP", Log::DEBUG, "Back from waitForMessage"); + log->debug(TAG, "Back from waitForMessage"); if (retval == 2) { @@ -128,12 +130,12 @@ void InputUDP::listenLoop() } else if (retval == 3) // quit { - Log::getInstance()->log("InputUDP", Log::DEBUG, "quit"); + log->debug(TAG, "quit"); break; } else { - log->log("InputUDP", Log::CRIT, "Wait for packet error"); + log->crit(TAG, "Wait for packet error"); return; } } @@ -141,7 +143,7 @@ void InputUDP::listenLoop() void InputUDP::processRequest(const void* data, UINT length) { - log->log("InputUDP", Log::DEBUG, "Got request"); + log->debug(TAG, "Got request"); char* temp = new char[length + 1]; memcpy(temp, data, length); @@ -149,7 +151,7 @@ void InputUDP::processRequest(const void* data, UINT length) UINT command = static_cast(atoi(temp)); delete[] temp; - log->log("InputUDP", Log::DEBUG, "Command %i recieved", command); + log->debug(TAG, "Command {} recieved", command); sendInputKey(command); } diff --git a/inputudp.h b/inputudp.h index 0b5096a..f875290 100644 --- a/inputudp.h +++ b/inputudp.h @@ -32,7 +32,7 @@ #include "udp4.h" #include "input.h" -class Log; +class LogNT; class InputUDP : public Input { @@ -55,7 +55,7 @@ class InputUDP : public Input bool initted{}; UDP4 udp4; // FIXME UDP6 ? - Log* log{}; + LogNT* log{}; std::thread listenThread; std::mutex threadStartProtect; diff --git a/log.h b/log.h index 5312544..814314d 100644 --- a/log.h +++ b/log.h @@ -45,18 +45,19 @@ class LogNT enum levels { TRACE, DEBUG, INFO, WARN, ERROR, CRIT }; - template void trace(const char* TAG, Ts... args) { log(TAG, TRACE, args...); } - template void debug(const char* TAG, Ts... args) { log(TAG, DEBUG, args...); } - template void info (const char* TAG, Ts... args) { log(TAG, INFO, args...); } - template void warn (const char* TAG, Ts... args) { log(TAG, WARN, args...); } - template void error(const char* TAG, Ts... args) { log(TAG, ERROR, args...); } - template void crit (const char* TAG, Ts... args) { log(TAG, CRIT, args...); } - + template void trace(const char* TAG, Ts... args) { ilog(TAG, TRACE, args...); } + template void debug(const char* TAG, Ts... args) { ilog(TAG, DEBUG, args...); } + template void info (const char* TAG, Ts... args) { ilog(TAG, INFO, args...); } + template void warn (const char* TAG, Ts... args) { ilog(TAG, WARN, args...); } + template void error(const char* TAG, Ts... args) { ilog(TAG, ERROR, args...); } + template void crit (const char* TAG, Ts... args) { ilog(TAG, CRIT, args...); } + void setExternLogger(void*) {}; + void unsetExternLogger() {}; template - void log(const char* TAG, int level, T fmtString, Ts... args) + void ilog(const char* TAG, int level, T fmtString, Ts... args) { if (!enabled) return; diff --git a/main.cc b/main.cc index b3c06f9..b4cffd5 100644 --- a/main.cc +++ b/main.cc @@ -76,7 +76,7 @@ int fdtty; struct vt_mode old_vtmode; #endif -const char* TAG = "Main"; +static const char* TAG = "Main"; // Linux main function and sighandler #ifndef WIN32 diff --git a/tcp.cc b/tcp.cc index 6cf82b9..a002c47 100644 --- a/tcp.cc +++ b/tcp.cc @@ -41,10 +41,12 @@ #include #include "defines.h" -#include "oldlog.h" +#include "log.h" #include "tcp.h" +static const char* TAG = "TCP"; + TCP::~TCP() { shutdown(); @@ -64,19 +66,19 @@ TCP::~TCP() bool TCP::init() { - logger = Log::getInstance(); + logger = LogNT::getInstance(); #ifdef WIN32 abortSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (abortSocket == INVALID_SOCKET) { - logger->log("TCP", Log::CRIT, "socket error"); + logger->crit(TAG, "socket error"); return false; } #else if (pipe2(abortPipe, O_NONBLOCK) == -1) { - logger->log("TCP", Log::CRIT, "pipe2 error"); + logger->crit(TAG, "pipe2 error"); return false; } #endif @@ -101,12 +103,12 @@ bool TCP::connect(const std::string& ip, USHORT port) if ((gaiResult != 0) || !aip) { - logger->log("TCP", Log::CRIT, "getaddrinfo error"); + logger->crit(TAG, "getaddrinfo error"); return false; } sockfd = socket(aip->ai_family, SOCK_STREAM, 0); - if (sockfd == -1) { logger->log("TCP", Log::CRIT, "socket error"); return false; } + if (sockfd == -1) { logger->crit(TAG, "socket error"); return false; } #ifdef WIN32 ULONG param = 1; @@ -134,7 +136,7 @@ bool TCP::connect(const std::string& ip, USHORT port) { CLOSESOCKET(sockfd); sockfd = -1; - logger->log("TCP", Log::CRIT, "connect error"); + logger->crit(TAG, "connect error"); return false; } @@ -168,14 +170,14 @@ bool TCP::connect(const std::string& ip, USHORT port) { CLOSESOCKET(sockfd); sockfd = -1; - logger->log("TCP", Log::INFO, "connect/select aborting"); + logger->info(TAG, "connect/select aborting"); return false; } if ((selectResult == 1) || FD_ISSET(sockfd, &writefds)) { freeaddrinfo(aip); - logger->log("TCP", Log::INFO, "Connected"); + logger->info(TAG, "Connected"); connected = true; return true; } @@ -183,7 +185,7 @@ bool TCP::connect(const std::string& ip, USHORT port) { CLOSESOCKET(sockfd); sockfd = -1; - logger->log("TCP", Log::CRIT, "connect/select error"); + logger->crit(TAG, "connect/select error"); return false; } } @@ -252,7 +254,7 @@ bool TCP::read(void* dst, ULONG numBytes, int timeoutSec) { if (++abortCount == 1000) { - logger->log("TCP", Log::ALERT, "abortCount = 1000 - runaway error, or packet arrived in > 1000 pieces??"); + logger->error(TAG, "abortCount = 1000 - runaway error, or packet arrived in > 1000 pieces??"); return false; } @@ -283,9 +285,9 @@ bool TCP::read(void* dst, ULONG numBytes, int timeoutSec) if (selectResult == 0) return false; #ifdef WIN32 - if (FD_ISSET(abortSocket, &readfds)) { logger->log("TCP", Log::DEBUG, "Aborting..."); return false; } + if (FD_ISSET(abortSocket, &readfds)) { logger->debug(TAG, "Aborting..."); return false; } #else - if (FD_ISSET(abortPipe[0], &readfds)) { logger->log("TCP", Log::DEBUG, "Aborting..."); return false; } + if (FD_ISSET(abortPipe[0], &readfds)) { logger->debug(TAG, "Aborting..."); return false; } #endif int recvResult = recv(sockfd, pointer, numBytes - totalReceived, 0); @@ -326,7 +328,7 @@ std::stringstream TCP::readString(bool* result, int timeoutSec) { if (++abortCount == 20) { - logger->log("TCP", Log::DEBUG, "abortCount = 20"); + logger->debug(TAG, "abortCount = 20"); return ss; } @@ -357,9 +359,9 @@ std::stringstream TCP::readString(bool* result, int timeoutSec) if (selectResult == 0) return ss; #ifdef WIN32 - if (FD_ISSET(abortSocket, &readfds)) { logger->log("TCP", Log::DEBUG, "Aborting..."); return ss; } + if (FD_ISSET(abortSocket, &readfds)) { logger->debug(TAG, "Aborting..."); return ss; } #else - if (FD_ISSET(abortPipe[0], &readfds)) { logger->log("TCP", Log::DEBUG, "Aborting..."); return ss; } + if (FD_ISSET(abortPipe[0], &readfds)) { logger->debug(TAG, "Aborting..."); return ss; } #endif int recvResult = recv(sockfd, &recStringBuf[recStringBufUsed], recStringBufSize - recStringBufUsed, 0); diff --git a/tcp.h b/tcp.h index d847e38..65931a5 100644 --- a/tcp.h +++ b/tcp.h @@ -33,7 +33,7 @@ struct MACAddress UCHAR mac[6]; }; -class Log; +class LogNT; class TCP { @@ -52,7 +52,7 @@ class TCP MACAddress getMAC(); private: - Log* logger; + LogNT* logger; int sockfd{-1}; bool connected{}; std::mutex writeMutex; diff --git a/teletextdecodervbiebu.h b/teletextdecodervbiebu.h index ef2fdb4..8dbfe9f 100644 --- a/teletextdecodervbiebu.h +++ b/teletextdecodervbiebu.h @@ -36,7 +36,7 @@ #define TXTDECVBIEBU_H #include "draintarget.h" -#include "oldlog.h" +#include "log.h" /* from osdteletext begin */ @@ -274,14 +274,14 @@ public: cTeletextChar getChar(int x, int y) { // Read character content from page if (x<0 || x>=40 || y<0 || y>=25) { - Log::getInstance()->log("TeletextDecoderVBIEBU", Log::DEBUG, "Warning: out of bounds read access to teletext page"); + LogNT::getInstance()->debug("TeletextDecoderVBIEBU", "Warning: out of bounds read access to teletext page"); return cTeletextChar(); } return Page[x][y].ToDirty(false); } bool isDirty(int x, int y) { if (x<0 || x>=40 || y<0 || y>=25) { - Log::getInstance()->log("TeletextDecoderVBIEBU", Log::DEBUG, "Warning: out of bounds dirty access to teletext page"); + LogNT::getInstance()->debug("TeletextDecoderVBIEBU", "Warning: out of bounds dirty access to teletext page"); return false; } return Page[x][y].GetDirty(); @@ -290,7 +290,7 @@ public: // Set character at given location if (x<0 || x>=40 || y<0 || y>=25) { - Log::getInstance()->log("TeletextDecoderVBIEBU", Log::DEBUG, "Warning: out of bounds write access to teletext page"); + LogNT::getInstance()->debug("TeletextDecoderVBIEBU", "Warning: out of bounds write access to teletext page"); return; } if (getChar(x,y) != c) { diff --git a/timers.cc b/timers.cc index 1ffe4eb..4a69709 100644 --- a/timers.cc +++ b/timers.cc @@ -17,10 +17,12 @@ along with VOMP. If not, see . */ -#include "oldlog.h" +#include "log.h" #include "timers.h" +static const char* TAG = "Timers"; + Timers* Timers::instance = NULL; Timers::Timers() @@ -42,12 +44,12 @@ Timers* Timers::getInstance() int Timers::init() { if (initted) return false; - logger = Log::getInstance(); + logger = LogNT::getInstance(); timersMutex.lock(); // Start thread with mutex locked recalc = true; timersThread = std::thread([this] { masterLoop(); }); - logger->log("Timers", Log::DEBUG, "Timers started"); + logger->debug(TAG, "Timers started"); initted = true; return true; } @@ -118,7 +120,7 @@ bool Timers::setTimerC(TimerReceiver* client, int clientReference, std::chrono:: { if (!initted) return 0; - logger->log("Timers", Log::DEBUG, "Starting set timer chrono"); + logger->debug(TAG, "Starting set timer chrono"); std::lock_guard lock(timersMutex); @@ -141,7 +143,7 @@ bool Timers::setTimerC(TimerReceiver* client, int clientReference, std::chrono:: } else { - logger->log("Timers", Log::DEBUG, "Editing existing timer"); + logger->debug(TAG, "Editing existing timer"); // A waiting timer has been edited recalc = true; @@ -161,7 +163,7 @@ bool Timers::setTimerC(TimerReceiver* client, int clientReference, std::chrono:: timerList.push_back(t); recalc = true; timersCond.notify_all(); - logger->log("Timers", Log::DEBUG, "Timer set for %p ref %i", client, clientReference); + logger->debug(TAG, "Timer set for {} ref {}", (void*)client, clientReference); return true; // unlock } @@ -256,7 +258,7 @@ void Timers::reap() // Master timers thread, mutex locked (or shutdown, mutex lo if (te->restartAfterFinish) { - logger->log("Timers", Log::DEBUG, "timerEventFinished RESTART for %p %i", te->client, te->clientReference); + logger->debug(TAG, "timerEventFinished RESTART for {} {}", (void*)te->client, te->clientReference); te->restartAfterFinish = false; te->running = false; te->completed = false; @@ -310,7 +312,7 @@ bool Timers::cancelTimer(TimerReceiver* client, int clientReference) if (!initted) return false; - logger->log("Timers", Log::DEBUG, "Starting cancel timer %p %i, list size = %i", client, clientReference, timerList.size()); + logger->debug(TAG, "Starting cancel timer {} {}, list size = {}", (void*)client, clientReference, timerList.size()); std::unique_lock lockWrapper(timersMutex); // lock @@ -341,7 +343,7 @@ bool Timers::cancelTimer(TimerReceiver* client, int clientReference) timerList.erase(i); delete foundTimerEvent; - logger->log("Timers", Log::DEBUG, "Removed timer for %p ref %i", client, clientReference); + logger->debug(TAG, "Removed timer for {} ref {}", (void*)client, clientReference); recalc = true; timersCond.notify_all(); // shutdown could be being called? notify_all guarantees we wake masterLoop return true; // unlock @@ -351,7 +353,7 @@ bool Timers::cancelTimer(TimerReceiver* client, int clientReference) { // Case 2 b. // The thread requesting cancelTimer is the timer thread itself, the timer has already fired. - logger->log("Timers", Log::DEBUG, "%p ref %i cancelTimer itself calling - ignore", client, clientReference); + logger->debug(TAG, "{} ref {} cancelTimer itself calling - ignore", (void*)client, clientReference); foundTimerEvent->restartAfterFinish = false; // in case a restart had already been set. return true; // unlock } @@ -363,10 +365,10 @@ bool Timers::cancelTimer(TimerReceiver* client, int clientReference) // So, wait on the cond and go around each time we wake. One of them will have been after the timerThread finished, // which turns it into a case 3. - logger->log("Timers", Log::DEBUG, "%p ref %i cancelTimer WAITING", client, clientReference); + logger->debug(TAG, "{} ref {} cancelTimer WAITING", (void*)client, clientReference); timersCond.wait(lockWrapper); //unlocks in wait // locked - logger->log("Timers", Log::DEBUG, "%p ref %i cancelTimer go-around", client, clientReference); + logger->debug(TAG, "{} ref {} cancelTimer go-around", (void*)client, clientReference); } // end of the big while loop } @@ -383,7 +385,7 @@ void TimerEvent::run() threadStartProtect.lock(); threadStartProtect.unlock(); - Log::getInstance()->log("Timers", Log::DEBUG, "sending timer to %p with parameter %u", client, clientReference); + LogNT::getInstance()->debug(TAG, "sending timer to {} with parameter {}", (void*)client, clientReference); client->timercall(clientReference); Timers::getInstance()->reapTimerEvent(this); }); diff --git a/timers.h b/timers.h index bf746b9..09733c5 100644 --- a/timers.h +++ b/timers.h @@ -75,7 +75,7 @@ class TimerEvent void run(); }; -class Log; +class LogNT; typedef std::list TimerList; class Timers @@ -96,7 +96,7 @@ class Timers void reapTimerEvent(TimerEvent*); // Internal only private: static Timers* instance; - Log* logger{}; + LogNT* logger{}; bool initted{}; bool quitThread{}; bool recalc{}; diff --git a/udp4.cc b/udp4.cc index 6b4f352..ee57155 100644 --- a/udp4.cc +++ b/udp4.cc @@ -36,10 +36,12 @@ #include #include "defines.h" -#include "oldlog.h" +#include "log.h" #include "udp4.h" +static const char* TAG = "UDP4"; + UDP4::~UDP4() { if (initted) shutdown(); @@ -181,7 +183,7 @@ bool UDP4::send(const char *ipa, USHORT port, char *message, int length) sentLength = sendto(socketnum, message, length, 0, reinterpret_cast(&sendAddr), addrlen); if (sentLength == length) return true; - Log::getInstance()->log("UDP6", Log::ERR, "sendto failed, errno = %i", errno); + LogNT::getInstance()->error(TAG, "sendto failed, errno = {}", errno); return false; } diff --git a/udp6.cc b/udp6.cc index cecf1ee..b2f9fdc 100644 --- a/udp6.cc +++ b/udp6.cc @@ -37,10 +37,12 @@ #include #include -#include "oldlog.h" +#include "log.h" #include "udp6.h" +static const char* TAG = "UDP6"; + UDP6::~UDP6() { if (initted) shutdown(); @@ -186,9 +188,9 @@ bool UDP6::send(const char *ipa, USHORT port, char *message, int length, bool mc { ifIndex = ifs[i].if_index; int res = setsockopt(socketnum, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifIndex, sizeof(ifIndex)); - Log::getInstance()->log("UDP6", Log::DEBUG, "Transmitting IPv6 MC UDP on %s", ifs[i].if_name); + LogNT::getInstance()->debug(TAG, "Transmitting IPv6 MC UDP on {}", ifs[i].if_name); res = sendto(socketnum, message, length, 0, reinterpret_cast(&sendAddr), addrlen); - Log::getInstance()->log("UDP6", Log::DEBUG, "Result: %i. Errno: %i", res, errno); + LogNT::getInstance()->debug(TAG, "Result: {}. Errno: {}", res, errno); errno = 0; } @@ -198,7 +200,7 @@ bool UDP6::send(const char *ipa, USHORT port, char *message, int length, bool mc { sentLength = sendto(socketnum, message, length, 0, reinterpret_cast(&sendAddr), addrlen); if (sentLength == length) return true; - Log::getInstance()->log("UDP6", Log::ERR, "sendto failed, errno = %i", errno); + LogNT::getInstance()->error(TAG, "sendto failed, errno = {}", errno); } return false; diff --git a/vdpc.cc b/vdpc.cc index f7dd58c..23e4552 100644 --- a/vdpc.cc +++ b/vdpc.cc @@ -26,11 +26,13 @@ #include #include -#include "oldlog.h" +#include "log.h" #include "wol.h" #include "vdpc.h" +static const char* TAG = "VDPC"; + void VDPC::TEMPaddCLIServer(const std::string& cliServer) { std::lock_guard lg(serversLock); @@ -99,7 +101,7 @@ int VDPC::go() do { - Log::getInstance()->log("VDPC", Log::DEBUG, "Sending broadcasts"); + LogNT::getInstance()->debug(TAG, "Sending broadcasts"); #ifdef IPV4 vdpc4.sendRequest(); @@ -109,7 +111,7 @@ int VDPC::go() #endif waitCond.wait_for(ul, std::chrono::milliseconds(1500), [this]{ return stopNow == true; }); - Log::getInstance()->log("VDPC", Log::DEBUG, "go() wait finished"); + LogNT::getInstance()->debug(TAG, "go() wait finished"); if (stopNow) break; if (servers.size() == 0) Wol::getInstance()->doWakeUp(); @@ -151,12 +153,12 @@ const VDRServer& VDPC::operator[](ULONG index) const bool VDPC::VDPC4::init(AddServerCallback& taddFunc) { - Log::getInstance()->log("VDPC4", Log::DEBUG, "init"); + LogNT::getInstance()->debug("VDPC4", "init"); addFunc = taddFunc; if (!udp4.init(0)) { - Log::getInstance()->log("VDPC4", Log::CRIT, "Failed to init VDPC4 UDP"); + LogNT::getInstance()->crit("VDPC4", "Failed to init VDPC4 UDP"); return false; } @@ -165,7 +167,7 @@ bool VDPC::VDPC4::init(AddServerCallback& taddFunc) void VDPC::VDPC4::run() { - Log::getInstance()->log("VDPC4", Log::DEBUG, "run"); + LogNT::getInstance()->debug("VDPC4", "run"); stopNow = false; startProtect.lock(); @@ -180,7 +182,7 @@ void VDPC::VDPC4::run() void VDPC::VDPC4::stop() { - Log::getInstance()->log("VDPC4", Log::DEBUG, "stop"); + LogNT::getInstance()->debug("VDPC4", "stop"); stopNow = true; @@ -200,33 +202,33 @@ void VDPC::VDPC4::stop() void VDPC::VDPC4::threadMethod() { - Log* logger = Log::getInstance(); + LogNT* logger = LogNT::getInstance(); #ifdef WIN32 quitPipe = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (quitPipe == INVALID_SOCKET) { - logger->log("VDPC4", Log::ERR, "socket() fail"); + logger->error("VDPC4", "socket() fail"); return; } #else if (pipe2(pfdsUDP4, O_NONBLOCK) == -1) { - logger->log("VDPC4", Log::ERR, "pipe2 error B"); + logger->error("VDPC4", "pipe2 error B"); return; } #endif while (!stopNow) { - Log::getInstance()->log("VDPC4", Log::DEBUG, "goto waitformessage"); + logger->debug("VDPC4", "goto waitformessage"); #ifdef WIN32 UCHAR retval = udp4.waitforMessage(3, quitPipe); #else UCHAR retval = udp4.waitforMessage(3, pfdsUDP4[0]); #endif - Log::getInstance()->log("VDPC4", Log::DEBUG, "backfrom waitformessage"); + logger->debug("VDPC4", "backfrom waitformessage"); if (retval == 2) // we got a reply { @@ -246,13 +248,13 @@ void VDPC::VDPC4::threadMethod() } } - Log::getInstance()->log("VDPC4", Log::DEBUG, "loop stopnow = %i", stopNow); + logger->debug("VDPC4", "loop stopnow = %i", stopNow); } } void VDPC::VDPC4::sendRequest() { - Log::getInstance()->log("VDPC4", Log::DEBUG, "broadcast"); + LogNT::getInstance()->debug("VDPC4", "broadcast"); char message[15]; memset(message, 0, 15); @@ -274,12 +276,12 @@ void VDPC::VDPC4::sendRequest() bool VDPC::VDPC6::init(AddServerCallback& taddFunc) { - Log::getInstance()->log("VDPC6", Log::DEBUG, "init"); + LogNT::getInstance()->debug("VDPC6", "init"); addFunc = taddFunc; if (!udp6.init(0)) { - Log::getInstance()->log("VDPC6", Log::CRIT, "Failed to init VDPC6 UDP"); + LogNT::getInstance()->crit("VDPC6", "Failed to init VDPC6 UDP"); return false; } @@ -288,7 +290,7 @@ bool VDPC::VDPC6::init(AddServerCallback& taddFunc) void VDPC::VDPC6::run() { - Log::getInstance()->log("VDPC6", Log::DEBUG, "run"); + LogNT::getInstance()->debug("VDPC6", "run"); stopNow = false; startProtect.lock(); @@ -303,7 +305,7 @@ void VDPC::VDPC6::run() void VDPC::VDPC6::stop() { - Log::getInstance()->log("VDPC6", Log::DEBUG, "stop"); + LogNT::getInstance()->debug("VDPC6", "stop"); stopNow = true; write(pfdsUDP6[1], "X", 1); @@ -315,20 +317,20 @@ void VDPC::VDPC6::stop() void VDPC::VDPC6::threadMethod() { - Log* logger = Log::getInstance(); + LogNT* logger = LogNT::getInstance(); if (pipe2(pfdsUDP6, O_NONBLOCK) == -1) { - logger->log("VDPC6", Log::ERR, "pipe2 error B"); + logger->error("VDPC6", "pipe2 error B"); return; } while (!stopNow) { - Log::getInstance()->log("VDPC6", Log::DEBUG, "goto waitformessage"); + logger->debug("VDPC6", "goto waitformessage"); UCHAR retval = udp6.waitforMessage(3, pfdsUDP6[0]); - Log::getInstance()->log("VDPC6", Log::DEBUG, "backfrom waitformessage"); + logger->debug("VDPC6", "backfrom waitformessage"); if (retval == 2) // we got a reply { @@ -348,13 +350,13 @@ void VDPC::VDPC6::threadMethod() } } - Log::getInstance()->log("VDPC6", Log::DEBUG, "loop stopnow = %i", stopNow); + logger->debug("VDPC6", "loop stopnow = %i", stopNow); } } void VDPC::VDPC6::sendRequest() { - Log::getInstance()->log("VDPC6", Log::DEBUG, "broadcast"); + LogNT::getInstance()->debug("VDPC6", "broadcast"); char message[15]; memset(message, 0, 15); diff --git a/vdr.cc b/vdr.cc index e756814..89bbc9a 100644 --- a/vdr.cc +++ b/vdr.cc @@ -42,6 +42,8 @@ #include "vdr.h" +static const char* TAG = "VDR"; + #define VOMP_PROTOCOL_VERSION 0x00000500 VDR* VDR::instance = NULL; @@ -79,7 +81,7 @@ SerializeBuffer * VDR::doRequestResponse(SerializeBuffer *rq,int cmd) { } delete rq; VDR_ResponsePacket *rp=RequestResponse(rt); - logger->log("doRequestResponse",Log::DEBUG,"got response %p",rp); + logger->debug(TAG, "Got response {}", (void*)rp); if ( !rp) { delete rt; return NULL; @@ -96,15 +98,15 @@ static int decodeResponse(SerializeBuffer *rp,VDR_Command *c) { ULONG expected=c->command; if (c->deserialize(rp) != 0) { delete rp; - Log::getInstance()->log("VDR", Log::ERR, "decodeResponse unable to deserialize for command %lu",expected); + Log::getInstance()->error(TAG, "decodeResponse unable to deserialize for command {}", expected); return -1; } delete rp; if (c->command != expected) { - Log::getInstance()->log("VDR", Log::ERR, "decodeResponse unexpected response received 0x%lx, expected 0x%lx",c->command,expected); + Log::getInstance()->error(TAG, "decodeResponse unexpected response received {:#x}, expected {:#x}", c->command, expected); return -1; } - Log::getInstance()->log("VDR", Log::DEBUG, "decodeResponse successfully decoded command 0x%lx",expected); + Log::getInstance()->error(TAG, "decodeResponse successfully decoded command {:#x}", expected); return 0; } @@ -138,7 +140,7 @@ int VDR::init() { if (initted) return 0; initted = 1; - logger = Log::getInstance(); + logger = LogNT::getInstance(); tcp.init(); return 1; } @@ -239,7 +241,7 @@ void VDR::disconnect() disconnecting = false; connected = false; - logger->log("VDR", Log::DEBUG, "Disconnect"); + logger->debug(TAG, "Disconnect"); } void VDR::setReceiveWindow(size_t size) @@ -251,7 +253,7 @@ void VDR::setReceiveWindow(size_t size) void VDR::threadMethod() { - logger->log("VDR", Log::DEBUG, "VDR RUN"); + logger->debug(TAG, "VDR RUN"); ULONG channelID; @@ -277,7 +279,7 @@ void VDR::threadMethod() if (!readSuccess) { - //logger->log("VDR", Log::DEBUG, "Net read timeout"); + //logger->debug(TAG, "Net read timeout"); if (!tcp.status()) { connectionDied(); return; } // return to stop this thread } @@ -285,10 +287,10 @@ void VDR::threadMethod() { if (lastKArecv < (timeNow - 5)) { - //logger->log("VDR", Log::DEBUG, "Sending KA packet"); + //logger->debug(TAG, "Sending KA packet"); if (!sendKA(timeNow)) { - logger->log("VDR", Log::DEBUG, "Could not send KA, calling connectionDied"); + logger->debug(TAG, "Could not send KA, calling connectionDied"); connectionDied(); return; } @@ -301,7 +303,7 @@ void VDR::threadMethod() { if (lastKAsent <= (timeNow - 10)) { - logger->log("VDR", Log::DEBUG, "lastKA over 10s ago, calling connectionDied"); + logger->debug(TAG, "lastKA over 10s ago, calling connectionDied"); connectionDied(); return; } @@ -343,7 +345,7 @@ void VDR::threadMethod() vresp = new VDR_ResponsePacket(); vresp->setResponse(requestID, reinterpret_cast(userData), userDataLength); // vresp now owns userData unless something calls vresp->getUserData() -// logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength); +// logger->debug(TAG, "Rxd a response packet, requestID={}, len={}", requestID, userDataLength); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) { @@ -386,7 +388,7 @@ void VDR::threadMethod() vresp = new VDR_ResponsePacket(); vresp->setStream(streamID, flag, reinterpret_cast(userData), userDataLength, channelID); - //logger->log("VDR", Log::DEBUG, "Rxd a stream packet, streamID=%lu, flag=%lu, len=%lu", streamID, flag, userDataLength); + //logger->debug(TAG, "Rxd a stream packet, streamID={}, flag={}, len={}", streamID, flag, userDataLength); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) { @@ -407,12 +409,12 @@ void VDR::threadMethod() { lastKAsent = 0; lastKArecv = KAreply; - //logger->log("VDR", Log::DEBUG, "Rxd correct KA reply"); + //logger->debug(TAG, "Rxd correct KA reply"); } } else { - logger->log("VDR", Log::ERR, "Rxd a response packet on channel %lu !!", channelID); + logger->error(TAG, "Rxd a response packet on channel {} !!", channelID); break; } @@ -447,13 +449,13 @@ void VDR::connectionDied() { vresp = new VDR_ResponsePacket(); vresp->setResponse(vdrpr->requestSerialNumber, NULL, 0); - logger->log("VDR", Log::DEBUG, "Timeouts: created blank response packet for request serial %lu", vdrpr->requestSerialNumber); + logger->debug(TAG, "Timeouts: created blank response packet for request serial {}", vdrpr->requestSerialNumber); edMutex.unlock(); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) { // If edFindAndCall returns true, edr was called and vresp was handed off. // else, delete vresp here. - logger->log("VDR", Log::ERR, "Timeouts: no waiting thread found for request serial %lu !!!", vdrpr->requestSerialNumber); + logger->error(TAG, "Timeouts: no waiting thread found for request serial {} !!!", vdrpr->requestSerialNumber); delete vresp; } edMutex.lock(); @@ -462,13 +464,13 @@ void VDR::connectionDied() { vresp = new VDR_ResponsePacket(); vresp->setStream(vdrpr->streamID, 2 /* connection-lost flag */ , NULL, 0, vdrpr->receiverChannel); - logger->log("VDR", Log::DEBUG, "Timeouts: created blank response packet for streamid %lu", vdrpr->streamID); + logger->debug(TAG, "Timeouts: created blank response packet for streamid {}", vdrpr->streamID); edMutex.unlock(); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) { // If edFindAndCall returns true, edr was called and vresp was handed off. // else, delete vresp here. - logger->log("VDR", Log::ERR, "Timeouts: no waiting stream receiver found for streamid %lu !!!", vdrpr->streamID); + logger->error(TAG, "Timeouts: no waiting stream receiver found for streamid {} !!!", vdrpr->streamID); delete vresp; } edMutex.lock(); @@ -479,7 +481,7 @@ void VDR::connectionDied() } edMutex.unlock(); // Ok, all event receviers should be dealt with. just in case there weren't any, inform control - logger->log("VDR", Log::DEBUG, "edUnlock at end of connectionDied"); + logger->debug(TAG, "edUnlock at end of connectionDied"); Control::getInstance()->connectionLost(); } @@ -495,7 +497,7 @@ bool VDR::ed_cb_find(EDReceiver* edr, void* userTag) // Is vresp for vdrpr ? ULONG packetChannel = vresp->getChannelID(); - //logger->log("VDR", Log::DEBUG, "TVMedia debug %d %d %x", vdrpr->receiverChannel,packetChannel,vdrpr); + //logger->debug(TAG, "TVMedia debug {} {} {:#x}", vdrpr->receiverChannel,packetChannel,vdrpr); if (vdrpr->receiverChannel != packetChannel) return false; if (packetChannel == CHANNEL_REQUEST_RESPONSE) @@ -516,11 +518,11 @@ bool VDR::ed_cb_find(EDReceiver* edr, void* userTag) VDR_ResponsePacket* VDR::RequestResponse(VDR_RequestPacket* vrp) { - //logger->log("VDR", Log::DEBUG, "RR %lu", vrp->getOpcode()); + //logger->debug(TAG, "RR {}", vrp->getOpcode()); if (!connected || disconnecting) { - logger->log("VDR", Log::DEBUG, "RR when !connected || disconnecting"); + logger->debug(TAG, "RR when !connected || disconnecting"); VDR_ResponsePacket* vresp = new VDR_ResponsePacket(); return vresp; // "no-response" return } @@ -548,12 +550,12 @@ VDR_ResponsePacket* VDR::RequestResponse(VDR_RequestPacket* vrp) } // Sleep and block this thread. The sleep unlocks the mutex -// logger->log("VDR", Log::DEBUG, "RR sleep - opcode %lu", vrp->getOpcode()); +// logger->debug(TAG, "RR sleep - opcode {}", vrp->getOpcode()); edSleepThisReceiver(&vdrpr); -// logger->log("VDR", Log::DEBUG, "RR unsleep"); +// logger->debug(TAG, "RR unsleep"); // Woken because a response packet has arrived, mutex will be locked -// logger->log("VDR", Log::DEBUG, "Packet delivered to me, requestID: %lu", vdrpr.save_vresp->getRequestID()); +// logger->debug(TAG, "Packet delivered to me, requestID: {}", vdrpr.save_vresp->getRequestID()); edMutex.unlock(); return vdrpr.save_vresp; @@ -615,7 +617,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake // delete the EDR. It's made once per media requested and wasn't owned/deleted by anything before VDR_ResponsePacket* vresp = reinterpret_cast(userTag); - Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia Pictures arrived VDR %x", vresp->getStreamID()); + LogNT::getInstance()->debug(TAG, "TVMedia Pictures arrived VDR %x", vresp->getStreamID()); OsdVector *osd=dynamic_cast(Osd::getInstance()); if (osd) osd->getPictReader()->receivePicture(vresp); // else delete vresp; //nonsense // only rpi does CHANNEL_TVMEDIA, rpi has osdvector. therefore, can't get here. @@ -642,9 +644,9 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne if (vresp->noResponse()) { delete vresp; return 0; } ULONG vdrTime = vresp->extractULONG(); - logger->log("VDR", Log::DEBUG, "vdrtime = %lu", vdrTime); + logger->debug(TAG, "vdrtime = {}", vdrTime); long vdrTimeOffset = vresp->extractLONG(); - logger->log("VDR", Log::DEBUG, "offset = %i", vdrTimeOffset); + logger->debug(TAG, "offset = {}", vdrTimeOffset); unsigned int version_min=vresp->extractULONG(); @@ -662,7 +664,7 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne newpref.audiopref = vresp->extractLONG(); newpref.subtitlepref = vresp->extractLONG(); newpref.langcode = vresp->extractStdString(); - //logger->log("VDR", Log::DEBUG, "Langpref %s %d %d", newpref.langcode.c_str(), newpref.audiopref, newpref.subtitlepref); + //logger->debug(TAG, "Langpref {} {} {}", newpref.langcode.c_str(), newpref.audiopref, newpref.subtitlepref); list.push_back(newpref); } } @@ -686,7 +688,7 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne int b = clock_settime(CLOCK_REALTIME, ¤tTime); - logger->log("VDR", Log::DEBUG, "set clock = %u", b); + logger->debug(TAG, "set clock = {}", b); // now make a TZ variable and set it char sign; @@ -700,17 +702,17 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne hours = (int)vdrTimeOffset / 3600; minutes = vdrTimeOffset % 3600; - logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); + logger->debug(TAG, "{} {} {}", sign, hours, minutes); minutes = (int)minutes / 60; - logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); + logger->debug(TAG, "{} {} {}", sign, hours, minutes); char newTZ[30]; sprintf(newTZ, "MVP%c%i:%i", sign, hours, minutes); setenv("TZ", newTZ, 1); - logger->log("VDR", Log::DEBUG, "Timezone data: %s", newTZ); + logger->debug(TAG, "Timezone data: {}", newTZ); #endif setCharset(Osd::getInstance()->charSet()); @@ -876,7 +878,7 @@ ChannelList* VDR::getChannelsList(ULONG type) if (chan->type == type && ((chan->vstreamtype==0x1b && h264support)|| (chan->vstreamtype!=0x1b &&mpeg2support)) ) { chanList->push_back(chan); - logger->log("VDR", Log::DEBUG, "Have added a channel to list. %lu %lu %s", chan->number, chan->type, chan->name); + logger->debug(TAG, "Have added a channel to list. {} {} {}", chan->number, chan->type, chan->name); if (chan->number > maxChannelNumber) maxChannelNumber = chan->number; } else @@ -927,7 +929,7 @@ int VDR::streamChannel(ULONG number, StreamReceiver* tstreamReceiver) } int toReturn = static_cast(vresp->extractULONG()); - logger->log("VDR", Log::DEBUG, "VDR said %lu to start streaming request", toReturn); + logger->debug(TAG, "VDR said {} to start streaming request", toReturn); delete vresp; return toReturn; @@ -967,7 +969,7 @@ UCHAR* VDR::getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived) if (vresp->serverError()) { - logger->log("VDR", Log::DEBUG, "Detected getblock 0"); + logger->debug(TAG, "Detected getblock 0"); *amountReceived = 0; delete vresp; return NULL; @@ -999,7 +1001,7 @@ ULLONG VDR::streamRecording(char* fileName, ULONG* totalFrames, bool* IsPesRecor *totalFrames = lengthFrames; *IsPesRecording = (isPesRecording);//convert Uchar to bool - logger->log("VDR", Log::DEBUG, "VDR said length is: %llu %lu, IsPesRecording %x", lengthBytes, lengthFrames, *IsPesRecording); + logger->debug(TAG, "VDR said length is: {} {}, IsPesRecording {:#x}", lengthBytes, lengthFrames, *IsPesRecording); return lengthBytes; } @@ -1016,7 +1018,7 @@ ULLONG VDR::positionFromFrameNumber(ULONG frameNumber) ULLONG position = vresp->extractULLONG(); delete vresp; - logger->log("VDR", Log::DEBUG, "VDR said new position is: %llu", position); + logger->debug(TAG, "VDR said new position is: {}", position); return position; } @@ -1033,7 +1035,7 @@ ULONG VDR::frameNumberFromPosition(ULLONG position) ULONG framenumber = vresp->extractULONG(); delete vresp; - logger->log("VDR", Log::DEBUG, "VDR said new framenumber is: %u", framenumber); + logger->debug(TAG, "VDR said new framenumber is: {}", framenumber); return framenumber; } @@ -1050,7 +1052,7 @@ bool VDR::getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfilePositio if (vresp->serverError()) { - logger->log("VDR", Log::DEBUG, "Detected getNextIFrame error"); + logger->debug(TAG, "Detected getNextIFrame error"); delete vresp; return false; } @@ -1061,7 +1063,7 @@ bool VDR::getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfilePositio delete vresp; - logger->log("VDR", Log::DEBUG, "VDR GNIF said %llu %lu %lu", *rfilePosition, *rframeNumber, *rframeLength); + logger->debug(TAG, "VDR GNIF said {} {} {}", *rfilePosition, *rframeNumber, *rframeLength); return true; } @@ -1109,7 +1111,7 @@ EventList* VDR::getChannelSchedule(ULONG number, time_t start, ULONG duration) delete vresp; - logger->log("VDR", Log::DEBUG, "Success got to end of getChannelSchedule"); + logger->debug(TAG, "Success got to end of getChannelSchedule"); return eventList; } @@ -1181,7 +1183,7 @@ RecTimerList* VDR::getRecTimersList() delete[] tempString; recTimerList->push_back(newRecTimer); - logger->log("VDR", Log::DEBUG, "TL: %lu %lu %lu %lu %lu %lu %lu %lu %s", + logger->debug(TAG, "TL: {} {} {} {} {} {} {} {} {}", newRecTimer->active, newRecTimer->recording, newRecTimer->pending, newRecTimer->priority, newRecTimer->lifeTime, newRecTimer->channelNumber, newRecTimer->startTime, newRecTimer->stopTime, newRecTimer->getFile()); } @@ -1220,7 +1222,7 @@ RecInfo* VDR::getRecInfo(char* fileName) if (vresp->serverError()) { - logger->log("VDR", Log::DEBUG, "Could not get rec info"); + logger->debug(TAG, "Could not get rec info"); delete vresp; return NULL; } @@ -1273,7 +1275,7 @@ ULLONG VDR::rescanRecording(ULONG* totalFrames) ULONG lengthFrames = vresp->extractULONG(); delete vresp; - logger->log("VDR", Log::DEBUG, "VDR said length is: %llu %lu", lengthBytes, lengthFrames); + logger->debug(TAG, "VDR said length is: {} {}", lengthBytes, lengthFrames); *totalFrames = lengthFrames; return lengthBytes; @@ -1302,7 +1304,7 @@ MarkList* VDR::getMarks(char* fileName) mark->pos = vresp->extractULONG(); markList->push_back(mark); - logger->log("VDR", Log::DEBUG, "Have added a mark to list. %lu", mark->pos); + logger->debug(TAG, "Have added a mark to list. {}", mark->pos); } delete vresp; @@ -1398,7 +1400,7 @@ MediaList * VDR::getRootList() { */ MediaList* VDR::getMediaList(const MediaURI * root) { - logger->log("VDR", Log::DEBUG, "getMediaList %s,d=%s, prov=%d", (root?root->getName():"NULL"), + logger->debug(TAG, "getMediaList {},d={}, prov={}", (root?root->getName():"NULL"), ((root && root->hasDisplayName())?root->getDisplayName():"NULL"), (root?root->getProvider():providerId)); MediaURI remoteURI(root); @@ -1451,7 +1453,7 @@ int VDR::openMedium(ULONG channel,const MediaURI *uri, ULLONG * size, ULONG x, if (decodeResponse(vresp,&response) != 0) { return -1; } - logger->log("VDR", Log::DEBUG, "openMedia len=%llu", *size); + logger->debug(TAG, "openMedia len={}", *size); return 0; } @@ -1542,7 +1544,7 @@ int VDR::closeMediaChannel(ULONG channel) { int VDR::deleteTimer(RecTimer* delTimer) { - logger->log("VDR", Log::DEBUG, "Delete timer called"); + logger->debug(TAG, "Delete timer called"); VDR_RequestPacket vrp; if (!vrp.init(VDR_DELETETIMER, false, 0)) return 0; @@ -1613,20 +1615,20 @@ int VDR::getLanguageContent(const std::string code, I18n::trans_table& texts) void VDR::shutdownVDR() { if(doVDRShutdown) - logger->log("VDR", Log::DEBUG, "Shutting down vdr"); + logger->debug(TAG, "Shutting down vdr"); else - logger->log("VDR", Log::DEBUG, "Shutting down vomp only"); + logger->debug(TAG, "Shutting down vomp only"); if(!doVDRShutdown || !connected || disconnecting) return; VDR_RequestPacket vrp; - logger->log("VDR", Log::DEBUG, "Sending shutdown"); + logger->debug(TAG, "Sending shutdown"); if (!vrp.init(VDR_SHUTDOWN, false, 0)) return; VDR_ResponsePacket* vresp = RequestResponse(&vrp); delete vresp; - logger->log("VDR", Log::DEBUG, "VDR shutdown"); + logger->debug(TAG, "VDR shutdown"); } void VDR::getScraperEventType(char * fileName, int & movieID, @@ -1638,9 +1640,9 @@ void VDR::getScraperEventType(char * fileName, int & movieID, VDR_RequestPacket vrp; if (!vrp.init(VDR_GETRECSCRAPEREVENTTYPE, true, strlen(fileName) + 1)) return; if (!vrp.addString(fileName)) return ; - Log::getInstance()->log("Recording", Log::DEBUG, "Before Response "); + logger->debug(TAG, "Before response"); VDR_ResponsePacket* vresp = RequestResponse(&vrp); - Log::getInstance()->log("Recording", Log::DEBUG, "After Response "); + logger->debug(TAG, "After response"); if (vresp->noResponse()) { delete vresp; return ; } int type = vresp->extractUCHAR(); if (type == 0) //serie @@ -1666,9 +1668,9 @@ void VDR::getScraperEventType(UINT channelid, UINT eventid, int & movieID, if (!vrp.init(VDR_GETEVENTSCRAPEREVENTTYPE, false, 0)) return; if (!vrp.addULONG(channelid)) return ; if (!vrp.addULONG(eventid)) return ; - Log::getInstance()->log("Recording", Log::DEBUG, "Before Response "); + logger->debug(TAG, "Before response"); VDR_ResponsePacket* vresp = RequestResponse(&vrp); - Log::getInstance()->log("Recording", Log::DEBUG, "After Response "); + logger->debug(TAG, "After response"); if (vresp->noResponse()) { delete vresp; return ; } int type = vresp->extractUCHAR(); if (type == 0) //serie @@ -1844,7 +1846,7 @@ ULONG VDR::loadTVMedia(TVMediaInfo& tvmedia) if (!vrp.addULONG(tvmedia.type_pict)) return ULONG_MAX; if (!vrp.addULONG(tvmedia.container)) return ULONG_MAX; if (!vrp.addULONG(tvmedia.container_member)) return ULONG_MAX; -/* Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia with ID %d %d; %d %d %d %d;%d", +/* logger->debug(TAG, "TVMedia with ID {} {}; {} {} {} {};{}", tvmedia.primary_id,tvmedia.secondary_id,tvmedia.type,tvmedia.type_pict, tvmedia.container,tvmedia.container_member,vrp.getSerial());*/ @@ -1927,7 +1929,7 @@ ULONG VDR::loadChannelLogo(TVMediaInfo & media) //if (vresp->noResponse()) { delete vresp; return ULONG_MAX; } delete vresp; -// Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia Channel Logo %d %x", +// logger->debug(TAG, "TVMedia Channel Logo {} {:#x}", // media.primary_id,vrp.getSerial()); return vrp.getSerial(); diff --git a/vdr.h b/vdr.h index e7c8edc..1d9c941 100644 --- a/vdr.h +++ b/vdr.h @@ -229,7 +229,7 @@ public ExternLogger void connectionDied(); bool sendKA(ULONG timeStamp); - Log* logger; + LogNT* logger; int initted{}; int findingServer{}; TCP tcp; -- 2.39.2