mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Added support for dynamic filenames in disk logstream.
This means you can use date properties like the current year, month or day in the filename. A list of possible replacement characters is here: %y = Year with two digits (e.g. 2002 becomes "02") %Y = Year with 4 digits %m = with two digits (e.g. March becomes "03") %M = Minute with two digits %d = Day of month with two digits (e.g. March, 1st becomes "01") %h = Hour as two digits %S = Seconds as two digits. It is hardly believed that this ever be used in reality. %w = Weekday as one digit. 0 means Sunday, 1 Monday and so on. %W = Weekday as three-character string. Possible values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat".
This commit is contained in:
parent
5dbef41f7b
commit
1082691f66
@ -39,10 +39,11 @@ if ( !defined('IN_PHPLOGCON') )
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
class LogStreamConfigDisk extends LogStreamConfig {
|
class LogStreamConfigDisk extends LogStreamConfig {
|
||||||
|
// Public properties
|
||||||
public $FileName = '';
|
public $FileName = '';
|
||||||
public $LineParserType = "syslog"; // Default = Syslog!
|
public $LineParserType = "syslog"; // Default = Syslog!
|
||||||
public $_lineParser = null;
|
public $_lineParser = null;
|
||||||
|
|
||||||
public function LogStreamFactory($o)
|
public function LogStreamFactory($o)
|
||||||
{
|
{
|
||||||
// An instance is created, then include the logstreamdisk class as well!
|
// An instance is created, then include the logstreamdisk class as well!
|
||||||
@ -79,5 +80,50 @@ class LogStreamConfigDisk extends LogStreamConfig {
|
|||||||
DieWithErrorMsg("Couldn't locate LineParser include file '" . $strIncludeFile . "'");
|
DieWithErrorMsg("Couldn't locate LineParser include file '" . $strIncludeFile . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper function to Set the FileName property
|
||||||
|
*/
|
||||||
|
public function SetFileName( $szNewVal )
|
||||||
|
{
|
||||||
|
// Replace dynamic variables if necessary
|
||||||
|
if ( strpos($szNewVal, "%") !== false )
|
||||||
|
{
|
||||||
|
OutputDebugMessage("LogStreamConfigDisk|SetFileName: Filename before replacing: " . $szNewVal, DEBUG_DEBUG);
|
||||||
|
|
||||||
|
// Create search and replace array
|
||||||
|
$search = array (
|
||||||
|
"%y", /* Year with two digits (e.g. 2002 becomes "02") */
|
||||||
|
"%Y", /* Year with 4 digits */
|
||||||
|
"%m", /* Month with two digits (e.g. March becomes "03") */
|
||||||
|
"%M", /* Minute with two digits */
|
||||||
|
"%d", /* Day of month with two digits (e.g. March, 1st becomes "01") */
|
||||||
|
"%h", /* Hour as two digits */
|
||||||
|
"%S", /* Seconds as two digits. It is hardly believed that this ever be used in reality. */
|
||||||
|
"%w", /* Weekday as one digit. 0 means Sunday, 1 Monday and so on. */
|
||||||
|
"%W", /* Weekday as three-character string. Possible values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat". */
|
||||||
|
);
|
||||||
|
$replace = array (
|
||||||
|
date("y"),
|
||||||
|
date("Y"),
|
||||||
|
date("m"),
|
||||||
|
date("i"),
|
||||||
|
date("d"),
|
||||||
|
date("H"),
|
||||||
|
date("s"),
|
||||||
|
date("w"),
|
||||||
|
date("D"),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do the replacing
|
||||||
|
$szNewVal = str_replace( $search, $replace, $szNewVal );
|
||||||
|
|
||||||
|
OutputDebugMessage("LogStreamConfigDisk|SetFileName: Filename after replacing: " . $szNewVal, DEBUG_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set Filename Property!
|
||||||
|
$this->FileName = $szNewVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -129,7 +129,7 @@ function InitSource(&$mysource)
|
|||||||
// Perform necessary include
|
// Perform necessary include
|
||||||
require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
|
require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
|
||||||
$mysource['ObjRef'] = new LogStreamConfigDisk();
|
$mysource['ObjRef'] = new LogStreamConfigDisk();
|
||||||
$mysource['ObjRef']->FileName = $mysource['DiskFile'];
|
$mysource['ObjRef']->SetFileName( $mysource['DiskFile'] );
|
||||||
$mysource['ObjRef']->LineParserType = $mysource['LogLineType'];
|
$mysource['ObjRef']->LineParserType = $mysource['LogLineType'];
|
||||||
}
|
}
|
||||||
else if ( $mysource['SourceType'] == SOURCE_DB )
|
else if ( $mysource['SourceType'] == SOURCE_DB )
|
||||||
|
@ -239,6 +239,8 @@ function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO)
|
|||||||
// Check if we should print the Error!
|
// Check if we should print the Error!
|
||||||
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
|
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
|
||||||
{
|
{
|
||||||
|
// Set Debugshow true
|
||||||
|
$content['SHOWDEBUGMSG'] = true;
|
||||||
$content['DEBUGMSG'][] = array(
|
$content['DEBUGMSG'][] = array(
|
||||||
"DBGLEVEL" => $szDbgLevel,
|
"DBGLEVEL" => $szDbgLevel,
|
||||||
"DBGLEVELTXT" => GetDebugModeString($szDbgLevel),
|
"DBGLEVELTXT" => GetDebugModeString($szDbgLevel),
|
||||||
|
@ -36,20 +36,23 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<!-- BEGIN DEBUGMSG -->
|
|
||||||
|
<!-- IF SHOWDEBUGMSG="true" -->
|
||||||
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="with_border">
|
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="with_border">
|
||||||
<tr>
|
<tr>
|
||||||
<td nowrap align="left" nowrap valign="top" class="cellmenu1_naked">{LN_DEBUGLEVEL}</td>
|
<td nowrap align="left" nowrap valign="top" class="cellmenu1_naked">{LN_DEBUGLEVEL}</td>
|
||||||
<td align="center" nowrap valign="top" class="cellmenu1_naked" width="100%">{LN_DEBUGMESSAGE}</td>
|
<td align="center" nowrap valign="top" class="cellmenu1_naked" width="100%">{LN_DEBUGMESSAGE}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<!-- BEGIN DEBUGMSG -->
|
||||||
<td nowrap align="center" nowrap valign="top" class="lineColouredWhite" bgcolor="{DBGLEVELBG}"><B>{DBGLEVELTXT}</B></td>
|
<tr>
|
||||||
<td align="left" nowrap valign="middle" class="line1">
|
<td nowrap align="center" nowrap valign="top" class="lineColouredWhite" bgcolor="{DBGLEVELBG}"><B>{DBGLEVELTXT}</B></td>
|
||||||
<div id="SearchCode">{DBGMSG}</div>
|
<td align="left" nowrap valign="middle" class="line1">
|
||||||
</td>
|
<div id="SearchCode">{DBGMSG}</div>
|
||||||
</tr>
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- END DEBUGMSG -->
|
||||||
</table>
|
</table>
|
||||||
<!-- END DEBUGMSG -->
|
<!-- ENDIF SHOWDEBUGMSG="true" -->
|
||||||
|
|
||||||
{EXTRA_FOOTER}
|
{EXTRA_FOOTER}
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user