From 1082691f669516840f67c8f45b963cb1d067e282 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 20 Mar 2009 15:35:26 +0100 Subject: [PATCH 1/3] 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". --- src/classes/logstreamconfigdisk.class.php | 50 ++++++++++++++++++++++- src/include/functions_config.php | 2 +- src/include/functions_frontendhelpers.php | 2 + src/templates/include_footer.html | 19 +++++---- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/classes/logstreamconfigdisk.class.php b/src/classes/logstreamconfigdisk.class.php index 8f957e6..657245c 100644 --- a/src/classes/logstreamconfigdisk.class.php +++ b/src/classes/logstreamconfigdisk.class.php @@ -39,10 +39,11 @@ if ( !defined('IN_PHPLOGCON') ) // --- class LogStreamConfigDisk extends LogStreamConfig { + // Public properties public $FileName = ''; public $LineParserType = "syslog"; // Default = Syslog! public $_lineParser = null; - + public function LogStreamFactory($o) { // 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 . "'"); } + /* + * 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; + } + + } -?> +?> \ No newline at end of file diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 6db76b8..8b720ec 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -129,7 +129,7 @@ function InitSource(&$mysource) // Perform necessary include require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php'); $mysource['ObjRef'] = new LogStreamConfigDisk(); - $mysource['ObjRef']->FileName = $mysource['DiskFile']; + $mysource['ObjRef']->SetFileName( $mysource['DiskFile'] ); $mysource['ObjRef']->LineParserType = $mysource['LogLineType']; } else if ( $mysource['SourceType'] == SOURCE_DB ) diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php index 10c7961..985e152 100644 --- a/src/include/functions_frontendhelpers.php +++ b/src/include/functions_frontendhelpers.php @@ -239,6 +239,8 @@ function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO) // Check if we should print the Error! if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 ) { + // Set Debugshow true + $content['SHOWDEBUGMSG'] = true; $content['DEBUGMSG'][] = array( "DBGLEVEL" => $szDbgLevel, "DBGLEVELTXT" => GetDebugModeString($szDbgLevel), diff --git a/src/templates/include_footer.html b/src/templates/include_footer.html index 16c2db0..6c2f89b 100644 --- a/src/templates/include_footer.html +++ b/src/templates/include_footer.html @@ -36,20 +36,23 @@ - + + - - - - + + + + + +
{LN_DEBUGLEVEL} {LN_DEBUGMESSAGE}
{DBGLEVELTXT} -
{DBGMSG}
-
{DBGLEVELTXT} +
{DBGMSG}
+
- + {EXTRA_FOOTER} From eb68f20101a761b645705b26c2dfa678b8ccb88e Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 20 Mar 2009 16:24:12 +0100 Subject: [PATCH 2/3] Fixed a case sensitive issue in db and pdo logstream This issue occured when the database driver returned mixed cased array keys. The workaround is to convert all array keys into lowercase automatically. --- src/classes/logstreamdb.class.php | 5 +++-- src/classes/logstreampdo.class.php | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index 25eddc0..a1ef332 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -1058,8 +1058,9 @@ class LogStreamDB extends LogStream { // Check if result was successfull! if ( $myRow === FALSE || !$myRow ) break; - - $this->bufferedRecords[$iBegin] = $myRow; + + // Keys will be converted into lowercase! + $this->bufferedRecords[$iBegin] = array_change_key_case($myRow, CASE_LOWER); $iBegin++; } diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index dc12f46..c00d0e0 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -1057,7 +1057,8 @@ class LogStreamPDO extends LogStream { if ( $myRow === FALSE || !$myRow ) break; - $this->bufferedRecords[$iBegin] = $myRow; + // Keys will be converted into lowercase! + $this->bufferedRecords[$iBegin] = array_change_key_case($myRow); $iBegin++; // Increment counter From fecd997477966a0125e22983808aff9d4495fbab Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 20 Mar 2009 17:30:07 +0100 Subject: [PATCH 3/3] Fixed db_template, propvalue and propvalue_text field in logcon_config table can be NULL now. This installation issues --- src/include/db_template.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/db_template.txt b/src/include/db_template.txt index 7e5480e..ad836a5 100644 --- a/src/include/db_template.txt +++ b/src/include/db_template.txt @@ -11,8 +11,8 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; DROP TABLE IF EXISTS `logcon_config`; CREATE TABLE `logcon_config` ( `propname` varchar(32) NOT NULL, - `propvalue` varchar(255) NOT NULL, - `propvalue_text` text NOT NULL, + `propvalue` varchar(255) NULL, + `propvalue_text` text NULL, `is_global` tinyint(1) NOT NULL, `userid` int(11) default NULL, `groupid` int(11) default NULL