Skip to content

Commit

Permalink
Support disabling addon debug logging in debug mode, closes kodi-pvr#228
Browse files Browse the repository at this point in the history
  • Loading branch information
phunkyfish committed May 21, 2019
1 parent b431649 commit 9b5340e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Within this tab more uncommon and advanced options can be configured.
- `Wakeup, then standby` - Similar to standby but first sends a wakeup command. Can be useful if you want to ensure all streams have stopped. Note: if you use CEC this could cause your TV to wake.
* **Custom live TV timeout (0 to use default)**: The timemout to use when trying to read live streams. Default for live streams is 0. Default for timeshifting is 10 seconds.
* **Stream read chunk size**: The chunk size used by Kodi for streams. Default 0 to leave it to Kodi to decide.
* **Ignore debug logging in debug mode**: Debug log statements will not be displayed for the addon even though debug logging is enabled in Kodi. This can be useful when trying to debug an issue in Kodi which is not addon related.
* **Enable debug logging in normal mode**: Debug log statements will display for the addon even though debug logging may not be enabled in Kodi. Note that all debug log statements will display at NOTICE level.
* **Enable trace logging in debug mode**: Very detailed and verbose log statements will display in addition to standard debug statements. If enabled along with `Enable debug logging in normal mode` both trace and debug will display without debug logging enabled. In this case both debug and trace log statements will display at NOTICE level.

Expand Down
14 changes: 12 additions & 2 deletions pvr.vuplus/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,12 @@ msgctxt "#30143"
msgid "Radio bouquet 5"
msgstr ""

#empty strings from id 30144 to 30409
#label: Advanced - ignoredebug
msgctxt "#30144"
msgid "Ignore debug logging in debug mode"
msgstr ""

#empty strings from id 30145 to 30409

###############
# application #
Expand Down Expand Up @@ -1242,7 +1247,12 @@ msgctxt "#30746"
msgid "Very detailed and verbose log statements will display in addition to standard debug statements. If enabled along with `Enable debug logging in normal mode` both trace and debug will display without debug logging enabled. In this case both debug and trace log statements will display at NOTICE level."
msgstr ""

#empty strings from id 30747 to 30759
#help: Advanced - ignoredebug
msgctxt "#30747"
msgid "Debug log statements will not be displayed for the addon even though debug logging is enabled in Kodi. This can be useful when trying to debug an issue in Kodi which is not addon related."
msgstr ""

#empty strings from id 30748 to 30759

#help info - Backend

Expand Down
15 changes: 13 additions & 2 deletions pvr.vuplus/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -838,14 +838,25 @@
<formatlabel>14049</formatlabel>
</control>
</setting>
<setting id="debugnormal" type="boolean" label="30111" help="30745">
<setting id="nodebug" type="boolean" label="30144" help="30747">
<level>1</level>
<default>false</default>
<control type="toggle" />
</setting>
<setting id="tracedebug" type="boolean" label="30104" help="30746">
<setting id="debugnormal" type="boolean" parent="nodebug" label="30111" help="30745">
<level>1</level>
<default>false</default>
<dependencies>
<dependency type="enable" setting="nodebug">false</dependency>
</dependencies>
<control type="toggle" />
</setting>
<setting id="tracedebug" type="boolean" parent="nodebug" label="30104" help="30746">
<level>1</level>
<default>false</default>
<dependencies>
<dependency type="enable" setting="nodebug">false</dependency>
</dependencies>
<control type="toggle" />
</setting>
</group>
Expand Down
9 changes: 6 additions & 3 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
/* Configure the logger */
Logger::GetInstance().SetImplementation([](LogLevel level, const char *message)
{
/* Don't log trace messages unless told so */
if (level == LogLevel::LEVEL_TRACE && !Settings::GetInstance().GetTraceDebug())
return;

/* Convert the log level */
addon_log_t addonLevel;

Expand All @@ -107,11 +111,10 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
addonLevel = addon_log_t::LOG_DEBUG;
}

/* Don't log trace messages unless told so */
if (level == LogLevel::LEVEL_TRACE && !Settings::GetInstance().GetTraceDebug())
if (addonLevel == addon_log_t::LOG_DEBUG && Settings::GetInstance().GetNoDebug())
return;

if (Settings::GetInstance().GetDebugNormal() && level == LogLevel::LEVEL_DEBUG)
if (addonLevel == addon_log_t::LOG_DEBUG && Settings::GetInstance().GetDebugNormal())
addonLevel = addon_log_t::LOG_NOTICE;

XBMC->Log(addonLevel, "%s", message);
Expand Down
7 changes: 6 additions & 1 deletion src/enigma2/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,11 @@ void Settings::ReadFromAddon()
if (!XBMC->GetSetting("streamreadchunksize", &m_streamReadChunkSize))
m_streamReadChunkSize = 0;

if (!XBMC->GetSetting("nodebug", &m_noDebug))
m_noDebug = false;

if (!XBMC->GetSetting("debugnormal", &m_debugNormal))
m_traceDebug = false;
m_debugNormal = false;

if (!XBMC->GetSetting("tracedebug", &m_traceDebug))
m_traceDebug = false;
Expand Down Expand Up @@ -507,6 +510,8 @@ ADDON_STATUS Settings::SetValue(const std::string &settingName, const void *sett
return SetSetting<int, ADDON_STATUS>(settingName, settingValue, m_readTimeout, ADDON_STATUS_NEED_RESTART, ADDON_STATUS_OK);
else if (settingName == "streamreadchunksize")
return SetSetting<int, ADDON_STATUS>(settingName, settingValue, m_streamReadChunkSize, ADDON_STATUS_OK, ADDON_STATUS_OK);
else if (settingName == "nodebug")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_noDebug, ADDON_STATUS_OK, ADDON_STATUS_OK);
else if (settingName == "debugnormal")
return SetSetting<bool, ADDON_STATUS>(settingName, settingValue, m_debugNormal, ADDON_STATUS_OK, ADDON_STATUS_OK);
else if (settingName == "tracedebug")
Expand Down
2 changes: 2 additions & 0 deletions src/enigma2/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ namespace enigma2
PowerstateMode GetPowerstateModeOnAddonExit() const { return m_powerstateMode; }
int GetReadTimeoutSecs() const { return m_readTimeout; }
int GetStreamReadChunkSizeKb() const { return m_streamReadChunkSize; }
bool GetNoDebug() const { return m_noDebug; };
bool GetDebugNormal() const { return m_debugNormal; };
bool GetTraceDebug() const { return m_traceDebug; };

Expand Down Expand Up @@ -354,6 +355,7 @@ namespace enigma2
PowerstateMode m_powerstateMode = PowerstateMode::DISABLED;
int m_readTimeout = 0;
int m_streamReadChunkSize = 0;
bool m_noDebug = false;
bool m_debugNormal = false;
bool m_traceDebug = false;

Expand Down

0 comments on commit 9b5340e

Please sign in to comment.