summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-08-27 10:58:33 +0000
committeralecpl <alec@alec.pl>2008-08-27 10:58:33 +0000
commitb77d0dd6c5574d9841cd5d040dfcc351a58ccb82 (patch)
tree6c8e872c3d4be368f2fa631f2421d3935e71ab21 /program
parentd5c539942e3cb4ad623a3f3f0344fc45af371981 (diff)
- added options to use syslog instead of log file (#1484850)
- added Logging & Debugging section in Installer - fixed config from $_POST for next installer steps saving - fixed and re-enabled debug_level setting in installer
Diffstat (limited to 'program')
-rw-r--r--program/include/bugs.inc7
-rw-r--r--program/include/main.inc22
-rw-r--r--program/include/rcmail.php8
-rw-r--r--program/include/rcube_config.php7
-rw-r--r--program/steps/mail/sendmail.inc10
5 files changed, 36 insertions, 18 deletions
diff --git a/program/include/bugs.inc b/program/include/bugs.inc
index 78808c321..3cd853478 100644
--- a/program/include/bugs.inc
+++ b/program/include/bugs.inc
@@ -84,8 +84,13 @@ function log_bug($arg_arr)
$CONFIG['log_dir'] = INSTALL_PATH.'logs';
// try to open specific log file for writing
- if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a'))
+ if ($CONFIG['log_driver'] == 'syslog')
{
+ syslog(LOG_ERR, $log_entry);
+ }
+ else if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a'))
+ {
+ // log_driver == 'file' is the default, assumed here.
fwrite($fp, $log_entry);
fclose($fp);
}
diff --git a/program/include/main.inc b/program/include/main.inc
index d79bd01d2..2b4797873 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -828,16 +828,24 @@ function write_log($name, $line)
date("d-M-Y H:i:s O", mktime()),
$line);
- if (empty($CONFIG['log_dir']))
- $CONFIG['log_dir'] = INSTALL_PATH.'logs';
+ if ($CONFIG['log_driver'] == 'syslog') {
+ if ($name == 'errors')
+ $prio = LOG_ERR;
+ else
+ $prio = LOG_INFO;
+ syslog($prio, $log_entry);
+ } else {
+ // log_driver == 'file' is assumed here
+ if (empty($CONFIG['log_dir']))
+ $CONFIG['log_dir'] = INSTALL_PATH.'logs';
- // try to open specific log file for writing
- if ($fp = @fopen($CONFIG['log_dir'].'/'.$name, 'a'))
- {
- fwrite($fp, $log_entry);
- fclose($fp);
+ // try to open specific log file for writing
+ if ($fp = @fopen($CONFIG['log_dir'].'/'.$name, 'a')) {
+ fwrite($fp, $log_entry);
+ fclose($fp);
}
}
+}
/**
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 8a061beb9..00dca6ea6 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -82,6 +82,13 @@ class rcmail
{
$config_all = $this->config->all();
+ // initialize syslog
+ if ($this->config->get('log_driver') == 'syslog') {
+ $syslog_id = $this->config->get('syslog_id', 'roundcube');
+ $syslog_facility = $this->config->get('syslog_facility', LOG_USER);
+ openlog($syslog_id, LOG_ODELAY, $syslog_facility);
+ }
+
// set task and action properties
$this->set_task(strip_quotes(get_input_value('_task', RCUBE_INPUT_GPC)));
$this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC));
@@ -111,7 +118,6 @@ class rcmail
$_SESSION['temp'] = true;
}
-
// create user object
$this->set_user(new rcube_user($_SESSION['user_id']));
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index db53fe7e1..43f735ba9 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -82,7 +82,12 @@ class rcube_config
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
- ini_set('error_log', $this->prop['log_dir'] . '/errors');
+
+ if ($this->prop['log_driver'] == 'syslog') {
+ ini_set('error_log', 'syslog');
+ } else {
+ ini_set('error_log', $this->prop['log_dir'].'/errors');
+ }
}
if ($this->prop['debug_level'] & 4) {
ini_set('display_errors', 1);
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 9888c5a97..25d95f949 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -420,19 +420,13 @@ else
{
if ($CONFIG['smtp_log'])
{
- $log_entry = sprintf(
+ write_log('sendmail', sprintf(
"[%s] User: %d on %s; Message for %s; %s\n",
date("d-M-Y H:i:s O", mktime()),
$_SESSION['user_id'],
$_SERVER['REMOTE_ADDR'],
$mailto,
- !empty($smtp_response) ? join('; ', $smtp_response) : '');
-
- if ($fp = @fopen($CONFIG['log_dir'].'/sendmail', 'a'))
- {
- fwrite($fp, $log_entry);
- fclose($fp);
- }
+ !empty($smtp_response) ? join('; ', $smtp_response) : ''));
}
rcmail_compose_cleanup();