Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1974900
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/kolab_sync_logger.php b/lib/kolab_sync_logger.php
index 2b592d3..4e89757 100644
--- a/lib/kolab_sync_logger.php
+++ b/lib/kolab_sync_logger.php
@@ -1,143 +1,143 @@
<?php
/*
+--------------------------------------------------------------------------+
| Kolab Sync (ActiveSync for Kolab) |
| |
| Copyright (C) 2011-2012, Kolab Systems AG |
| |
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU Affero General Public License as published |
| by the Free Software Foundation, either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public License |
| along with this program. If not, see <http://www.gnu.org/licenses/> |
+--------------------------------------------------------------------------+
| Author: Aleksander Machniak <machniak@kolabsys.com> |
+--------------------------------------------------------------------------+
*/
/**
* Class for logging messages into log file(s)
*/
class kolab_sync_logger extends Zend_Log
{
public $mode;
/**
* Constructor
*/
function __construct($mode = null)
{
$this->mode = intval($mode);
$r = new ReflectionClass($this);
$this->_priorities = $r->getConstants();
}
public function __call($method, $params)
{
$method = strtoupper($method);
if ($this->_priorities[$method] <= $this->mode) {
$this->log(array_shift($params), $method);
}
}
/**
* Message logger
*
* @param string $message Log message
* @param int|string $method Message severity
*/
public function log($message, $method, $extras = null)
{
$rcube = rcube::get_instance();
$logfile = $rcube->config->get('activesync_log_file');
$format = $rcube->config->get('log_date_format', 'd-M-Y H:i:s O');
$log_dir = $rcube->config->get('log_dir');
if (is_numeric($method)) {
$mode = $method;
$method = array_search($method, $this->_priorities);
}
else {
$mode = $this->_priorities[$method];
}
if ($mode > $this->mode) {
return;
}
// if log_file is configured all logs will go to it
// otherwise use separate file for info/debug and warning/error
if (!$logfile) {
switch ($mode) {
case self::DEBUG:
case self::INFO:
case self::NOTICE:
$file = 'console';
break;
default:
$file = 'errors';
break;
}
$logfile = $log_dir . DIRECTORY_SEPARATOR . $file;
}
else if ($logfile[0] != '/') {
$logfile = $log_dir . DIRECTORY_SEPARATOR . $logfile;
}
if (!is_string($message)) {
$message = var_export($message, true);
}
// add user/request information to the log
if ($mode <= self::WARN) {
$device = array();
$params = array('cmd' => 'Cmd', 'device' => 'DeviceId', 'type' => 'DeviceType');
if (!empty($this->username)) {
$device['user'] = $this->username;
}
foreach ($params as $key => $val) {
if ($val = $_GET[$val]) {
$device[$key] = $val;
}
}
if (!empty($device)) {
$message = @json_encode($device) . ' ' . $message;
}
}
$date = rcube_utils::date_format($format);
$logline = sprintf("[%s]: [%s] %s\n", $date, $method, $message);
if ($fp = @fopen($logfile, 'a')) {
fwrite($fp, $logline);
fflush($fp);
fclose($fp);
return;
}
if ($mode <= self::WARN) {
// send error to PHPs error handler if write to file didn't succeed
- trigger_error($message, E_USER_ERROR);
+ trigger_error($message, E_USER_WARNING);
}
}
/**
* Set current user name to add into error log
*/
public function set_username($username)
{
$this->username = $username;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Sep 15, 9:32 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
287517
Default Alt Text
(5 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment