diff --git a/www/admin/smarty_test.php b/www/admin/smarty_test.php index 71639ddf..702dbbdd 100644 --- a/www/admin/smarty_test.php +++ b/www/admin/smarty_test.php @@ -4,6 +4,7 @@ $DEBUG_ALL = 1; $PRINT_ALL = 1; $DB_DEBUG = 1; + $LOG_PER_RUN = 1; define('USE_DATABASE', true); require("header.inc"); diff --git a/www/libs/Class.Basic.inc b/www/libs/Class.Basic.inc index ebe6c747..d185a004 100644 --- a/www/libs/Class.Basic.inc +++ b/www/libs/Class.Basic.inc @@ -119,10 +119,12 @@ private $log_file_name_ext = 'log'; // use this for date rotate public $log_max_filesize = 0; // set in kilobytes private $log_print_file = 'error_msg##LEVEL####CLASS####PAGENAME####DATE##'; + private $log_file_unique_id; // a unique ID set only once for call derived from this class public $log_print_file_date = 1; // if set add Y-m-d and do automatic daily rotation public $log_per_level = 0; // set, it will split per level (first parameter in debug call) public $log_per_class = 0; // set, will split log per class public $log_per_page = 0; // set, will split log per called file + public $log_per_run = 0; // create a new log file per run (time stamp + unique ID) public $starttime; // start time if time debug is used public $endtime; // end time if time debug is used @@ -215,6 +217,18 @@ if (isset($GLOBALS['PRINT_ALL'])) $this->print_output_all = $GLOBALS['PRINT_ALL']; + // GLOBAL rules for log writing + if (isset($GLOBALS['LOG_PRINT_FILE_DATE'])) + $this->log_print_file_date = $GLOBALS['LOG_PRINT_FILE_DATE']; + if (isset($GLOBALS['LOG_PER_LEVEL'])) + $this->log_per_level = $GLOBALS['LOG_PER_LEVEL']; + if (isset($GLOBALS['LOG_PER_CLASS'])) + $this->log_per_class = $GLOBALS['LOG_PER_CLASS']; + if (isset($GLOBALS['LOG_PER_PAGE'])) + $this->log_per_page = $GLOBALS['LOG_PER_PAGE']; + if (isset($GLOBALS['LOG_PER_RUN'])) + $this->log_per_run = $GLOBALS['LOG_PER_RUN']; + // set the regex for checking emails $this->email_regex = "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,6}){1}$"; // this is for error check parts in where the email regex failed @@ -326,7 +340,7 @@ // this has to be changed, not returned here, this is the last class to close // return $this->error_msg; // close open file handles - $this->fdebug_fp('c'); +// $this->fdebug_fp('c'); } // ************************************************************* @@ -598,7 +612,18 @@ // init base file path $fn = ROOT.LOG.$this->log_print_file.'.'.$this->log_file_name_ext; - $rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d'); // add date to file + if ($this->log_per_run) + { + if ($GLOBALS['LOG_FILE_UNIQUE_ID']) + $this->log_file_unique_id = $GLOBALS['LOG_FILE_UNIQUE_ID']; + if (!$this->log_file_unique_id) + $GLOBALS['LOG_FILE_UNIQUE_ID'] = $this->log_file_unique_id = substr(hash('sha1', uniqid(mt_rand(), true)), 0, 8); + $rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d').'_U_'.$this->log_file_unique_id; // add 8 char unique string + } + else + { + $rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d'); // add date to file + } $fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename $rpl_string = !$this->log_per_level ? '' : '_'.$level; // if request to write to one file diff --git a/www/libs/Class.Login.inc b/www/libs/Class.Login.inc index acfd65b5..ac98d5bd 100644 --- a/www/libs/Class.Login.inc +++ b/www/libs/Class.Login.inc @@ -90,6 +90,9 @@ // DESC : cunstroctuor, does ALL, opens db, works through connection checks, closes itself public function __construct($db_config, $lang = 'en_utf8', $debug = 0, $db_debug = 0, $echo = 1, $print = 0) { + // log login data for this class only + $this->log_per_class = 1; + // create db connection and init base class parent::__construct($db_config, $debug, $db_debug, $echo, $print); @@ -100,9 +103,6 @@ exit; } - // log login data for this class only - $this->log_per_class = 1; - // get the language sub class & init it _spl_autoload('Class.l10n.inc'); $this->l = new l10n($lang);