mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 03:09:21 +02:00
Added option to send debug messages from phpLogCon to local syslog server
On Linux, the debug messages (warnings and error's for now) will be send to the local syslog server. On Windows, the debug messages will appear in the windows application eventlog.
This commit is contained in:
parent
d768ed6068
commit
78d9ac01d9
@ -132,8 +132,9 @@ if ( isset($_POST['op']) )
|
||||
if ( isset ($_POST['MiscShowDebugGridCounter']) ) { $content['MiscShowDebugGridCounter'] = 1; } else { $content['MiscShowDebugGridCounter'] = 0; }
|
||||
if ( isset ($_POST['MiscShowPageRenderStats']) ) { $content['MiscShowPageRenderStats'] = 1; } else { $content['MiscShowPageRenderStats'] = 0; }
|
||||
if ( isset ($_POST['MiscEnableGzipCompression']) ) { $content['MiscEnableGzipCompression'] = 1; } else { $content['MiscEnableGzipCompression'] = 0; }
|
||||
if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; }
|
||||
if ( isset ($_POST['SuppressDuplicatedMessages']) ) { $content['SuppressDuplicatedMessages'] = 1; } else { $content['SuppressDuplicatedMessages'] = 0; }
|
||||
if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; }
|
||||
if ( isset ($_POST['MiscDebugToSyslog']) ) { $content['MiscDebugToSyslog'] = 1; } else { $content['MiscDebugToSyslog'] = 0; }
|
||||
|
||||
// Read Text number fields
|
||||
if ( isset ($_POST['ViewMessageCharacterLimit']) && is_numeric($_POST['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_POST['ViewMessageCharacterLimit']; }
|
||||
@ -177,7 +178,6 @@ if ( isset($_POST['op']) )
|
||||
if ( isset ($_POST['User_MiscShowDebugGridCounter']) ) { $USERCFG['MiscShowDebugGridCounter'] = 1; } else { $USERCFG['MiscShowDebugGridCounter'] = 0; }
|
||||
if ( isset ($_POST['User_MiscShowPageRenderStats']) ) { $USERCFG['MiscShowPageRenderStats'] = 1; } else { $USERCFG['MiscShowPageRenderStats'] = 0; }
|
||||
if ( isset ($_POST['User_MiscEnableGzipCompression']) ) { $USERCFG['MiscEnableGzipCompression'] = 1; } else { $USERCFG['MiscEnableGzipCompression'] = 0; }
|
||||
// DISABLED FOR USER! if ( isset ($_POST['User_DebugUserLogin']) ) { $USERCFG['DebugUserLogin'] = 1; } else { $USERCFG['DebugUserLogin'] = 0; }
|
||||
if ( isset ($_POST['User_SuppressDuplicatedMessages']) ) { $USERCFG['SuppressDuplicatedMessages'] = 1; } else { $USERCFG['SuppressDuplicatedMessages'] = 0; }
|
||||
|
||||
// Read Text number fields
|
||||
@ -209,8 +209,10 @@ if ($content['MiscShowDebugMsg'] == 1) { $content['MiscShowDebugMsg_checked'] =
|
||||
if ($content['MiscShowDebugGridCounter'] == 1) { $content['MiscShowDebugGridCounter_checked'] = "checked"; } else { $content['MiscShowDebugGridCounter_checked'] = ""; }
|
||||
if ($content['MiscShowPageRenderStats'] == 1) { $content['MiscShowPageRenderStats_checked'] = "checked"; } else { $content['MiscShowPageRenderStats_checked'] = ""; }
|
||||
if ($content['MiscEnableGzipCompression'] == 1) { $content['MiscEnableGzipCompression_checked'] = "checked"; } else { $content['MiscEnableGzipCompression_checked'] = ""; }
|
||||
if ($content['DebugUserLogin'] == 1) { $content['DebugUserLogin_checked'] = "checked"; } else { $content['DebugUserLogin_checked'] = ""; }
|
||||
if ($content['SuppressDuplicatedMessages'] == 1) { $content['SuppressDuplicatedMessages_checked'] = "checked"; } else { $content['SuppressDuplicatedMessages_checked'] = ""; }
|
||||
|
||||
if ($content['DebugUserLogin'] == 1) { $content['DebugUserLogin_checked'] = "checked"; } else { $content['DebugUserLogin_checked'] = ""; }
|
||||
if ($content['MiscDebugToSyslog'] == 1) { $content['MiscDebugToSyslog_checked'] = "checked"; } else { $content['MiscDebugToSyslog_checked'] = ""; }
|
||||
// ---
|
||||
|
||||
// --- Init for Style field!
|
||||
|
@ -118,7 +118,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
|
||||
else
|
||||
{
|
||||
if ( isset($arrArguments[SYSLOG_MESSAGE]) && strlen($arrArguments[SYSLOG_MESSAGE]) > 0 )
|
||||
OutputDebugMessage("Unparseable syslog msg - '" . $arrArguments[SYSLOG_MESSAGE] . "'");
|
||||
OutputDebugMessage("Unparseable syslog msg - '" . $arrArguments[SYSLOG_MESSAGE] . "'", DEBUG_ERROR);
|
||||
}
|
||||
|
||||
// If SyslogTag is set, we check for MessageType!
|
||||
|
@ -88,7 +88,7 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
|
||||
else
|
||||
{
|
||||
if ( isset($arrArguments[SYSLOG_MESSAGE]) && strlen($arrArguments[SYSLOG_MESSAGE]) > 0 )
|
||||
OutputDebugMessage("Unparseable Winsyslog message - '" . $arrArguments[SYSLOG_MESSAGE] . "'");
|
||||
OutputDebugMessage("Unparseable Winsyslog message - '" . $arrArguments[SYSLOG_MESSAGE] . "'", DEBUG_ERROR);
|
||||
}
|
||||
|
||||
// If SyslogTag is set, we check for MessageType!
|
||||
|
@ -54,6 +54,7 @@ $CFG['UserDBLoginRequired'] = false;
|
||||
|
||||
// --- Misc Options
|
||||
$CFG['MiscShowDebugMsg'] = 0; // if enabled, you will get additional output on certain places
|
||||
$CFG['MiscDebugToSyslog'] = 0; // if enabled, debug messages from phpLogCon will be send to syslog on linux, and into the EventLog on Windows
|
||||
$CFG['MiscShowDebugGridCounter'] = 0; // Only for debugging purposes, will add a counter column into the grid!
|
||||
$CFG["MiscShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings
|
||||
$CFG['MiscEnableGzipCompression'] = 1; // If enabled, phplogcon will use gzip compression for output, we recommend
|
||||
|
@ -388,6 +388,10 @@ function CheckAndSetRunMode()
|
||||
|
||||
// Obtain max_execution_time
|
||||
$MaxExecutionTime = ini_get("max_execution_time");
|
||||
|
||||
// Define and Inits Syslog variables now!
|
||||
define_syslog_variables();
|
||||
openlog("phpLogCon", LOG_PID, LOG_USER);
|
||||
|
||||
// --- Check necessary PHP Extensions!
|
||||
$loadedExtensions = get_loaded_extensions();
|
||||
@ -402,7 +406,7 @@ function CheckAndSetRunMode()
|
||||
if ( in_array("mysql", $loadedExtensions) ) { $content['MYSQL_IS_ENABLED'] = true; } else { $content['MYSQL_IS_ENABLED'] = false; }
|
||||
// Check PDO Extension
|
||||
if ( in_array("PDO", $loadedExtensions) ) { $content['PDO_IS_ENABLED'] = true; } else { $content['PDO_IS_ENABLED'] = false; }
|
||||
|
||||
// ---
|
||||
}
|
||||
|
||||
function InitRuntimeInformations()
|
||||
@ -878,7 +882,7 @@ function GetEventTime($szTimStr)
|
||||
$eventtime[EVTIME_MICROSECONDS] = 0;
|
||||
|
||||
// Print Error!
|
||||
OutputDebugMessage("GetEventTime got an unparsable time '" . $szTimStr . "', returning 0");
|
||||
OutputDebugMessage("GetEventTime got an unparsable time '" . $szTimStr . "', returning 0", DEBUG_WARN);
|
||||
}
|
||||
|
||||
// return result!
|
||||
@ -1101,7 +1105,6 @@ function SaveGeneralSettingsIntoDB()
|
||||
WriteConfigValue( "MiscShowDebugGridCounter", true );
|
||||
WriteConfigValue( "MiscShowPageRenderStats", true );
|
||||
WriteConfigValue( "MiscEnableGzipCompression", true );
|
||||
WriteConfigValue( "DebugUserLogin", true );
|
||||
WriteConfigValue( "SuppressDuplicatedMessages", true );
|
||||
|
||||
WriteConfigValue( "ViewMessageCharacterLimit", true );
|
||||
@ -1115,6 +1118,10 @@ function SaveGeneralSettingsIntoDB()
|
||||
// Extra Fields
|
||||
WriteConfigValue( "DefaultViewsID", true );
|
||||
WriteConfigValue( "DefaultSourceID", true );
|
||||
|
||||
// GLOBAL ONLY
|
||||
WriteConfigValue( "DebugUserLogin", true );
|
||||
WriteConfigValue( "MiscDebugToSyslog", true );
|
||||
}
|
||||
|
||||
function SaveUserGeneralSettingsIntoDB()
|
||||
|
@ -262,7 +262,7 @@ function GetTimeStampFromTimeString($szTimeString)
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebugMessage("Unparseable Time in GetTimeStampFromTimeString - '" . $szTimeString . "'");
|
||||
OutputDebugMessage("Unparseable Time in GetTimeStampFromTimeString - '" . $szTimeString . "'", DEBUG_WARN);
|
||||
return $szTimeString;
|
||||
}
|
||||
}
|
||||
|
@ -232,8 +232,9 @@ function GetFormatedDate($evttimearray)
|
||||
return $szDateFormatted = date("Y-m-d H:i:s", $evttimearray[EVTIME_TIMESTAMP] );
|
||||
}
|
||||
|
||||
function OutputDebugMessage($szDbg)
|
||||
function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO)
|
||||
{
|
||||
// Check if we should print the Error!
|
||||
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
|
||||
{
|
||||
print("<table width=\"600\" align=\"center\" class=\"with_border\">");
|
||||
@ -241,6 +242,31 @@ function OutputDebugMessage($szDbg)
|
||||
print("<td>" . $szDbg . "</td></tr>");
|
||||
print("</table><br>");
|
||||
}
|
||||
|
||||
// Check if the user wants to syslog the error!
|
||||
if ( GetConfigSetting("MiscDebugToSyslog", 0, CFGLEVEL_GLOBAL) == 1 )
|
||||
{
|
||||
syslog(GetPriorityFromDebugLevel($szDbgLevel), $szDbg);
|
||||
}
|
||||
}
|
||||
|
||||
function GetPriorityFromDebugLevel( $DebugLevel )
|
||||
{
|
||||
switch ( $DebugLevel )
|
||||
{
|
||||
case DEBUG_ULTRADEBUG:
|
||||
return LOG_DEBUG;
|
||||
case DEBUG_DEBUG:
|
||||
return LOG_INFO;
|
||||
case DEBUG_INFO:
|
||||
return LOG_NOTICE;
|
||||
case DEBUG_WARN:
|
||||
return LOG_WARNING;
|
||||
case DEBUG_ERROR:
|
||||
return LOG_ERR;
|
||||
case DEBUG_ERROR_WTF:
|
||||
return LOG_CRIT;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -83,7 +83,8 @@ $content['LN_GEN_GLOBALVALUE'] = "Global value";
|
||||
$content['LN_GEN_PERSONALVALUE'] = "Personal (User)value";
|
||||
$content['LN_GEN_DISABLEUSEROPTIONS'] = "Click here to disable personal options";
|
||||
$content['LN_GEN_ENABLEUSEROPTIONS'] = "Click here to enable personal options";
|
||||
|
||||
$content['LN_ADMIN_GLOBALONLY'] = "Global Options Only";
|
||||
$content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server";
|
||||
|
||||
// User Center
|
||||
$content['LN_USER_CENTER'] = "User Options";
|
||||
|
@ -83,7 +83,8 @@ $content['LN_GEN_GLOBALVALUE'] = "Global value";
|
||||
$content['LN_GEN_PERSONALVALUE'] = "Personal (User)value";
|
||||
$content['LN_GEN_DISABLEUSEROPTIONS'] = "Click here to disable personal options";
|
||||
$content['LN_GEN_ENABLEUSEROPTIONS'] = "Click here to enable personal options";
|
||||
|
||||
$content['LN_ADMIN_GLOBALONLY'] = "Global Options Only";
|
||||
$content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server";
|
||||
|
||||
// User Center
|
||||
$content['LN_USER_CENTER'] = "User Options";
|
||||
|
@ -53,7 +53,8 @@ $content['LN_GEN_GLOBALVALUE'] = "Global value";
|
||||
$content['LN_GEN_PERSONALVALUE'] = "Personal (User)value";
|
||||
$content['LN_GEN_DISABLEUSEROPTIONS'] = "Click here to disable personal options";
|
||||
$content['LN_GEN_ENABLEUSEROPTIONS'] = "Click here to enable personal options";
|
||||
|
||||
$content['LN_ADMIN_GLOBALONLY'] = "Global Options Only";
|
||||
$content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server";
|
||||
|
||||
// General Options
|
||||
$content['LN_ADMIN_GLOBFRONTEND'] = "Global frontend options";
|
||||
|
@ -211,12 +211,17 @@
|
||||
<td align="right" class="line2" ><input type="checkbox" name="User_MiscEnableGzipCompression" value="yes" {User_MiscEnableGzipCompression_checked}></td>
|
||||
<!-- ENDIF ENABLEUSEROPTIONS="true" -->
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center" valign="top" class="title">
|
||||
<strong>{LN_ADMIN_GLOBALONLY}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="cellmenu2" nowrap><b>{LN_GEN_DEBUGUSERLOGIN}</b></td>
|
||||
<td align="right" class="line1" ><input type="checkbox" name="DebugUserLogin" value="yes" {DebugUserLogin_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
|
||||
<!-- IF ENABLEUSEROPTIONS="true" -->
|
||||
<td align="right" class="line1" > </td>
|
||||
<!-- ENDIF ENABLEUSEROPTIONS="true" -->
|
||||
<td align="right" class="line1" colspan="2"><input type="checkbox" name="DebugUserLogin" value="yes" {DebugUserLogin_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="cellmenu2" nowrap><b>{LN_GEN_DEBUGTOSYSLOG}</b></td>
|
||||
<td align="right" class="line2" colspan="2"><input type="checkbox" name="MiscDebugToSyslog" value="yes" {MiscDebugToSyslog_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="3">
|
||||
|
Loading…
x
Reference in New Issue
Block a user