mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-23 01:55:27 +03:00
ee498eadf9
* fix: move debug mode to config * fix: also move debug_whitelist to .ini config * fix: move logic back to Debug class * docs * docs * fix: disable debug mode by default * fix: restore previous behavior for alerts * fix: center-align alert text
29 lines
923 B
PHP
29 lines
923 B
PHP
<?php
|
|
|
|
class Debug
|
|
{
|
|
/**
|
|
* Convenience function for Configuration::getConfig('system', 'enable_debug_mode')
|
|
*/
|
|
public static function isEnabled(): bool
|
|
{
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
$enableDebugMode = Configuration::getConfig('system', 'enable_debug_mode');
|
|
$debugModeWhitelist = Configuration::getConfig('system', 'debug_mode_whitelist') ?: [];
|
|
if ($enableDebugMode && ($debugModeWhitelist === [] || in_array($ip, $debugModeWhitelist))) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function log($message)
|
|
{
|
|
$e = new \Exception();
|
|
$trace = trace_from_exception($e);
|
|
// Drop the current frame
|
|
array_pop($trace);
|
|
$lastFrame = $trace[array_key_last($trace)];
|
|
$text = sprintf('%s(%s): %s', $lastFrame['file'], $lastFrame['line'], $message);
|
|
Logger::debug($text);
|
|
}
|
|
}
|