improved logging for the gui

Change-Id: I31d0dbb70b8d8184ce1f48d0161ddaf9e6c8d9ca
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-09-21 21:59:57 +02:00
parent 4602ecd4a7
commit ba52fa3c99
11 changed files with 25 additions and 24 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
define('BUILD', '2014-01-29 858'); define('NORMAL', 1);
define('DEBUG', 5);
$config = array(); $config = array();
@ -10,12 +11,6 @@ $config = array();
* variable to be overridden in config-site.php * variable to be overridden in config-site.php
*/ */
$config['PILERGETD_HOST'] = '';
$config['PILERGETD_PORT'] = 10091;
$config['PILERGETD_READ_LENGTH'] = 8192;
$config['PILERGETD_TIMEOUT'] = 5;
$config['PILERGETD_PASSWORD'] = '';
$config['BRANDING_TEXT'] = ''; $config['BRANDING_TEXT'] = '';
$config['BRANDING_URL'] = ''; $config['BRANDING_URL'] = '';
$config['BRANDING_LOGO'] = ''; $config['BRANDING_LOGO'] = '';
@ -153,7 +148,7 @@ $config['ENABLE_LDAP_IMPORT_FEATURE'] = 0;
$config['ENABLE_FOLDER_RESTRICTIONS'] = 0; $config['ENABLE_FOLDER_RESTRICTIONS'] = 0;
$config['SEARCH_RESULT_CHECKBOX_CHECKED'] = 0; $config['SEARCH_RESULT_CHECKBOX_CHECKED'] = 0;
$config['HELPER_URL'] = ''; $config['HELPER_URL'] = '';
$config['ENABLE_SYSLOG'] = 1; $config['LOG_LEVEL'] = NORMAL;
$config['REWRITE_MESSAGE_ID'] = 0; $config['REWRITE_MESSAGE_ID'] = 0;
$config['RESTORE_EMAILS_AS_ATTACHMENT'] = 0; $config['RESTORE_EMAILS_AS_ATTACHMENT'] = 0;
$config['RESTRICTED_AUDITOR'] = 0; $config['RESTRICTED_AUDITOR'] = 0;

View File

@ -22,7 +22,7 @@ $language = new Language();
Registry::set('language', $language); Registry::set('language', $language);
if(ENABLE_SYSLOG == 1) { openlog("piler-webui", LOG_PID, LOG_MAIL); } openlog("piler-webui", LOG_PID, LOG_MAIL);
/* check if user has authenticated himself. If not, we send him to login */ /* check if user has authenticated himself. If not, we send him to login */

View File

@ -85,7 +85,7 @@ class ModelAccountingAccounting extends Model
} }
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added",date(DATE_TEMPLATE, $return['starttimestamp']),date(DATE_TEMPLATE, $return['stoptimestamp']),$return['deletedstats'],$return['addedstats'])); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added",date(DATE_TEMPLATE, $return['starttimestamp']),date(DATE_TEMPLATE, $return['stoptimestamp']),$return['deletedstats'],$return['addedstats'])); }
return $return; return $return;
} }

View File

@ -74,7 +74,7 @@ class ModelAuditAudit extends Model {
$query = $this->db->query("SELECT COUNT(*) AS count FROM " . TABLE_AUDIT . " $where", $arr); $query = $this->db->query("SELECT COUNT(*) AS count FROM " . TABLE_AUDIT . " $where", $arr);
$n = $query->row['count']; $n = $query->row['count'];
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("audit query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->row['count'])); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("audit query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->row['count'])); }
} }
else { $n = MAX_AUDIT_HITS; } else { $n = MAX_AUDIT_HITS; }
@ -87,7 +87,7 @@ class ModelAuditAudit extends Model {
$this->session->set("audit_query", array('where' => $where, 'sortorder' => $sortorder, 'arr' => $arr)); $this->session->set("audit_query", array('where' => $where, 'sortorder' => $sortorder, 'arr' => $arr));
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("audit query: '%s', param: '%s' in %.2f s, %d hits", $query->query, implode(' ', $arr), $query->exec_time, $query->num_rows)); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("audit query: '%s', param: '%s' in %.2f s, %d hits", $query->query, implode(' ', $arr), $query->exec_time, $query->num_rows)); }
if(isset($query->rows)) { if(isset($query->rows)) {

View File

@ -55,7 +55,7 @@ class ModelPolicyRetention extends Model {
$query = $this->db->query("UPDATE " . VIEW_MESSAGES . " SET retained = ? WHERE arrived > ? AND (todomain=? OR fromdomain=?)", array($retained, $start_ts, $data['domain'], $data['domain'])); $query = $this->db->query("UPDATE " . VIEW_MESSAGES . " SET retained = ? WHERE arrived > ? AND (todomain=? OR fromdomain=?)", array($retained, $start_ts, $data['domain'], $data['domain']));
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("update retention date: domain='%s', days=%d, hits=%d, exec time=%.2f sec", $data['domain'], $data['days'], $this->db->countAffected(), $query->exec_time)); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("update retention date: domain='%s', days=%d, hits=%d, exec time=%.2f sec", $data['domain'], $data['days'], $this->db->countAffected(), $query->exec_time)); }
return $this->db->countAffected(); return $this->db->countAffected();
} }

View File

@ -62,6 +62,8 @@ class ModelSearchMessage extends Model {
if($id == '' || !preg_match("/^([0-9a-f]+)$/", $id)) { return $s; } if($id == '' || !preg_match("/^([0-9a-f]+)$/", $id)) { return $s; }
if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, DECRYPT_BINARY . " $id"); }
$handle = popen(DECRYPT_BINARY . " $id", "r"); $handle = popen(DECRYPT_BINARY . " $id", "r");
while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))) { while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))) {
$s .= $buf; $s .= $buf;
@ -89,6 +91,8 @@ class ModelSearchMessage extends Model {
if($piler_id == '' || $attachment_id == '' || !preg_match("/^([0-9a-f]+)$/", $piler_id) || !preg_match("/^([0-9m]+)$/", $attachment_id)) { return $data; } if($piler_id == '' || $attachment_id == '' || !preg_match("/^([0-9a-f]+)$/", $piler_id) || !preg_match("/^([0-9m]+)$/", $attachment_id)) { return $data; }
if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, DECRYPT_ATTACHMENT_BINARY . " $piler_id $attachment_id"); }
$handle = popen(DECRYPT_ATTACHMENT_BINARY . " $piler_id $attachment_id", "r"); $handle = popen(DECRYPT_ATTACHMENT_BINARY . " $piler_id $attachment_id", "r");
while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))){ while(($buf = fread($handle, DECRYPT_BUFFER_LENGTH))){
$data .= $buf; $data .= $buf;

View File

@ -148,7 +148,7 @@ class ModelUserAuth extends Model {
foreach($params as $param) { foreach($params as $param) {
$ret = $this->checkLoginAgainstLDAP_real($username, $password, $data, $param); $ret = $this->checkLoginAgainstLDAP_real($username, $password, $data, $param);
syslog(LOG_INFO, "ldap auth result against " . $param['ldap_host'] . " / " . $param['ldap_type'] . ": $ret"); if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "ldap auth result against " . $param['ldap_host'] . " / " . $param['ldap_type'] . ": $ret"); }
if($ret == 1) { return $ret; } if($ret == 1) { return $ret; }
} }
@ -208,7 +208,7 @@ class ModelUserAuth extends Model {
$ldap_auth = new LDAP($ldap_host, $a['dn'], $password); $ldap_auth = new LDAP($ldap_host, $a['dn'], $password);
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, "ldap auth against '" . $ldap_host . "', dn: '" . $a['dn'] . "', result: " . $ldap_auth->is_bind_ok()); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "ldap auth against '" . $ldap_host . "', dn: '" . $a['dn'] . "', result: " . $ldap_auth->is_bind_ok()); }
if($ldap_auth->is_bind_ok()) { if($ldap_auth->is_bind_ok()) {
@ -241,7 +241,7 @@ class ModelUserAuth extends Model {
} }
} }
} }
else if(ENABLE_SYSLOG == 1) { else if(LOG_LEVEL >= NORMAL) {
syslog(LOG_INFO, "cannot bind to '" . $ldap_host . "' as '" . $ldap_helper_dn . "'"); syslog(LOG_INFO, "cannot bind to '" . $ldap_host . "' as '" . $ldap_helper_dn . "'");
} }
@ -281,7 +281,7 @@ class ModelUserAuth extends Model {
$data = array(); $data = array();
foreach($e as $a) { foreach($e as $a) {
//syslog(LOG_INFO, "checking ldap entry dn: " . $a['dn'] . ", cn: " . $a['cn']); if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking ldap entry dn: " . $a['dn'] . ", cn: " . $a['cn']); }
foreach (array("mail", "mailalternateaddress", "proxyaddresses", "zimbraMailForwardingAddress", "member", "memberOfGroup") as $mailattr) { foreach (array("mail", "mailalternateaddress", "proxyaddresses", "zimbraMailForwardingAddress", "member", "memberOfGroup") as $mailattr) {
if(isset($a[$mailattr])) { if(isset($a[$mailattr])) {
@ -289,7 +289,7 @@ class ModelUserAuth extends Model {
if(is_array($a[$mailattr])) { if(is_array($a[$mailattr])) {
for($i = 0; $i < $a[$mailattr]['count']; $i++) { for($i = 0; $i < $a[$mailattr]['count']; $i++) {
//syslog(LOG_INFO, "checking entry: " . $a[$mailattr][$i]); if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking entry: " . $a[$mailattr][$i]); }
$a[$mailattr][$i] = strtolower($a[$mailattr][$i]); $a[$mailattr][$i] = strtolower($a[$mailattr][$i]);
@ -305,7 +305,7 @@ class ModelUserAuth extends Model {
} }
} }
else { else {
//syslog(LOG_INFO, "checking entry #2: " . $a[$mailattr]); if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking entry #2: " . $a[$mailattr]); }
$email = strtolower(preg_replace("/^([\w]+)\:/i", "", $a[$mailattr])); $email = strtolower(preg_replace("/^([\w]+)\:/i", "", $a[$mailattr]));
if(validemail($email) && !in_array($email, $data)) { array_push($data, $email); } if(validemail($email) && !in_array($email, $data)) { array_push($data, $email); }
@ -440,7 +440,7 @@ class ModelUserAuth extends Model {
if(isset($u[1])) { $username = $u[1]; } if(isset($u[1])) { $username = $u[1]; }
else { $username = $_SERVER['REMOTE_USER']; } else { $username = $_SERVER['REMOTE_USER']; }
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, "sso login: $username"); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "sso login: $username"); }
$ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD); $ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD);
@ -455,7 +455,7 @@ class ModelUserAuth extends Model {
$username = strtolower(preg_replace("/^smtp\:/i", "", $username)); $username = strtolower(preg_replace("/^smtp\:/i", "", $username));
if($username == '') { if($username == '') {
syslog(LOG_INFO, "no email address found for " . $a['dn']); if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, "no email address found for " . $a['dn']); }
return 0; return 0;
} }

View File

@ -24,7 +24,7 @@ Registry::set('load', $loader);
$language = new Language(); $language = new Language();
Registry::set('language', $language); Registry::set('language', $language);
if(ENABLE_SYSLOG == 1) { openlog("piler-webui", LOG_PID, LOG_MAIL); } openlog("piler-webui", LOG_PID, LOG_MAIL);
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX); $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX);

View File

@ -36,7 +36,7 @@ class LDAP {
$results = ldap_get_entries($this->link, $sr); $results = ldap_get_entries($this->link, $sr);
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("ldap query: base dn='%s', filter='%s', attr='%s', %d hits", $basedn, $filter, implode(" ", $justthese), $results['count'])); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("ldap query: base dn='%s', filter='%s', attr='%s', %d hits", $basedn, $filter, implode(" ", $justthese), $results['count'])); }
for($i=0; $i < $results['count']; $i++) { for($i=0; $i < $results['count']; $i++) {
for($k=0; $k < $results[$i]['count']; $k++) { for($k=0; $k < $results[$i]['count']; $k++) {

View File

@ -30,6 +30,8 @@ class MySQL {
public function query($sql, $arr = array()) { public function query($sql, $arr = array()) {
$query = new stdClass(); $query = new stdClass();
if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "sql=$sql, arr=" . implode(";", $arr)); }
$query->error = 1; $query->error = 1;
$query->errmsg = "Error"; $query->errmsg = "Error";
$query->query = $sql; $query->query = $sql;

View File

@ -70,7 +70,7 @@ class Sphinx {
if($v[0] == "total_found") { $query->total_found = $v[1]; } if($v[0] == "total_found") { $query->total_found = $v[1]; }
} }
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("sphinx query: '%s' in %.2f s, %d hits, %d total found", $query->query, $query->exec_time, $query->num_rows, $query->total_found)); } if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("sphinx query: '%s' in %.2f s, %d hits, %d total found", $query->query, $query->exec_time, $query->num_rows, $query->total_found)); }
$session = Registry::get('session'); $session = Registry::get('session');
$sphx_query = ''; $sphx_query = '';