From: hickert Date: Wed, 23 May 2007 06:18:38 +0000 (+0000) Subject: Updated logging X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=81f633b7705e796c0645ce62036d3580a9a51461;p=gosa.git Updated logging git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6438 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_acl.inc b/include/class_acl.inc index 99adff3fc..23db48299 100644 --- a/include/class_acl.inc +++ b/include/class_acl.inc @@ -1032,7 +1032,9 @@ class acl extends plugin $this->cleanup(); $ldap->modify ($this->attrs); - @log::log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + if(count($this->attrs)){ + @log::log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } show_ldap_error($ldap->get_error(), sprintf(_("Saving ACLs with dn '%s' failed."),$this->dn)); diff --git a/include/class_log.inc b/include/class_log.inc index 3b8a56c1a..e41beba15 100644 --- a/include/class_log.inc +++ b/include/class_log.inc @@ -59,28 +59,38 @@ class log { /* Create data object */ $entry = array(); $entry['timestamp'] = time(); - $entry['user'] = $ui->dn; + $entry['user'] = @$ui->dn; $entry['action'] = $action; $entry['objecttype']= $objecttype; $entry['object'] = $object; $entry['changes'] = $changes; $entry['result'] = $result; + + if(!isset($this->config->current['LOGGING']) && empty($entry['user'])){ + $entry['user'] = "unknown"; + } /* Check if all given values are valid */ $msgs = @log::check($entry); if(count($msgs)){ foreach($msgs as $msg){ trigger_error("Logging failed, reason was: ".$msg); - print_red("Logging failed, reason was: ".$msg); + print_red("Logging failed, reason was: ".$msg); } + }else{ - /* Start logging for configured methods */ - if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)syslog(,|$)/i",$this->config->current['LOGGING'])){ + if(!isset($this->config->current['LOGGING'])){ @log::log_into_syslog($entry); - } - if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)mysql(,|$)/i",$this->config->current['LOGGING'])){ - @log::log_into_db($entry); + }else{ + + /* Start logging for configured methods */ + if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)syslog(,|$)/i",$this->config->current['LOGGING'])){ + @log::log_into_syslog($entry); + } + if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)mysql(,|$)/i",$this->config->current['LOGGING'])){ + @log::log_into_db($entry); + } } } } @@ -89,11 +99,11 @@ class log { function check($entry = array()) { $msgs = array(); - if(!isset($entry['user']) || empty($entry['user'])){ - $msgs[] = "Currently active user is empty."; - } + # if(!isset($entry['user']) || empty($entry['user'])){ + # $msgs[] = "Currently active user is empty."; + # } - if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view"))){ + if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security"))){ $msgs[] = "Invalid option specified '".$entry['action']."'"; } diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 6cbec1b4e..3714609db 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -222,7 +222,7 @@ class plugin */ function execute() { - gosa_log("ACL ".get_class($this)." - ".$this->acl_category." - ".$this->acl_base); + @log::log("view","acl/".get_class($this),$this->dn,array(),"ACL ".get_class($this)." - ".$this->acl_category." - ".$this->acl_base); /* This one is empty currently. Fabian - please fill in the docu code */ $_SESSION['current_class_for_help'] = get_class($this); @@ -1527,7 +1527,7 @@ class plugin /* Update userinfo if necessary */ if($_SESSION['ui']->dn == $old_dn){ $_SESSION['ui']->dn = $new_dn; - gosa_log(_("Updated current user dn from '".$old_dn."' to '".$new_dn."'")); + @log::log("view","acl/".get_class($this),$this->dn,array(),"Updated current user dn from '".$old_dn."' to '".$new_dn."'"); } /* Object was moved, ensure that all acls will be moved too */ diff --git a/include/php_setup.inc b/include/php_setup.inc index e83379c98..7d6c73870 100644 --- a/include/php_setup.inc +++ b/include/php_setup.inc @@ -57,7 +57,7 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline) if((isset($config->data['MAIN']['DISPLAYERRORS']))&&(!preg_match("/^true$/i",$config->data['MAIN']['DISPLAYERRORS']))){ /* Write to syslog */ - gosa_log ("PHP error: $errstr ($errfile, line $errline)"); + @log::log("view","error","",array(),"PHP error: $errstr ($errfile, line $errline)"); return; } } diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index ef45e7732..33c730945 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -1039,7 +1039,8 @@ class sieveManagement extends plugin if($script['EDITED']){ $data = $this->scripts[$key]['SCRIPT']; if(!$this->sieve_handle->sieve_sendscript($script['NAME'], addcslashes ($data,"\\"))){ - gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw)); + @log::log("modify","users/mailAccount".get_class($this),$script['NAME'],"Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw)); + $everything_went_fine = FALSE; print_red(to_string($this->sieve_handle->error_raw)); $this->scripts[$key]['MSG'] = "".