Changeset 1683 in subversion


Ignore:
Timestamp:
Aug 27, 2008 6:58:33 AM (5 years ago)
Author:
alec
Message:
  • 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
Location:
trunk/roundcubemail
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r1681 r1683  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42008/08/27 (alec) 
     5---------- 
     6- Added options to use syslog instead of log file (#1484850) 
     7- Added Logging & Debugging section in Installer 
    38 
    492008/08/26 (alec) 
  • trunk/roundcubemail/config/main.inc.php.dist

    r1649 r1683  
    1919$rcmail_config['debug_level'] = 1; 
    2020 
     21// log driver:  'syslog' or 'file'. 
     22$rcmail_config['log_driver'] = 'file'; 
     23 
     24// Syslog ident string to use, if using the 'syslog' log driver. 
     25$rcmail_config['syslog_id'] = 'roundcube'; 
     26 
     27// Syslog facility to use, if using the 'syslog' log driver. 
     28// For possible values see installer or http://php.net/manual/en/function.openlog.php 
     29$rcmail_config['syslog_facility'] = LOG_USER; 
     30 
     31// use this folder to store log files (must be writebale for apache user) 
     32// This is used by the 'file' log driver. 
     33$rcmail_config['log_dir'] = 'logs/'; 
     34 
     35// use this folder to store temp files (must be writeable for apache user) 
     36$rcmail_config['temp_dir'] = 'temp/'; 
     37 
    2138// enable caching of messages and mailbox data in the local database. 
    2239// this is recommended if the IMAP server does not run on the same machine 
     
    97114// includes should be interpreted as PHP files 
    98115$rcmail_config['skin_include_php'] = FALSE; 
    99  
    100 // use this folder to store temp files (must be writeable for apache user) 
    101 $rcmail_config['temp_dir'] = 'temp/'; 
    102  
    103 // use this folder to store log files (must be writeable for apache user) 
    104 $rcmail_config['log_dir'] = 'logs/'; 
    105116 
    106117// session lifetime in minutes 
  • trunk/roundcubemail/installer/check.php

    r1681 r1683  
    117117        $RCI->pass($classname); 
    118118    } 
    119     else if ($classname == 'DB' || ($classname == 'MDB2' && class_exists('DB'))) { 
    120         $RCI->na($classname, 'Use ' . ($classname == 'DB' ? 'MDB2' : 'DB') . ' instead'); 
    121     } 
    122119    else { 
    123120        $RCI->fail($classname, "Failed to load $file", $source_urls[$classname]); 
  • trunk/roundcubemail/installer/config.php

    r1681 r1683  
    1616  'preview_pane' => 1, 
    1717  'htmleditor' => 1, 
     18  'debug_level' => 1, 
    1819); 
    1920 
     
    4849<legend>General configuration</legend> 
    4950<dl class="configblock"> 
    50 <!-- 
    51 <dt id="cgfblockgeneral" class="propname">debug_level</dt> 
    52 <dd> 
    53 <?php 
    54 /* 
     51 
     52<dt class="propname">product_name</dt> 
     53<dd> 
     54<?php 
     55 
     56$input_prodname = new html_inputfield(array('name' => '_product_name', 'size' => 30, 'id' => "cfgprodname")); 
     57echo $input_prodname->show($RCI->getprop('product_name')); 
     58 
     59?> 
     60<div>The name of your service (used to compose page titles)</div> 
     61</dd> 
     62 
     63<dt class="propname">temp_dir</dt> 
     64<dd> 
     65<?php 
     66 
     67$input_tempdir = new html_inputfield(array('name' => '_temp_dir', 'size' => 30, 'id' => "cfgtempdir")); 
     68echo $input_tempdir->show($RCI->getprop('temp_dir')); 
     69 
     70?> 
     71<div>Use this folder to store temp files (must be writebale for webserver)</div> 
     72</dd> 
     73 
     74 
     75<dt class="propname">ip_check</dt> 
     76<dd> 
     77<?php 
     78 
     79$check_ipcheck = new html_checkbox(array('name' => '_ip_check', 'id' => "cfgipcheck")); 
     80echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)); 
     81 
     82?> 
     83<label for="cfgipcheck">Check client IP in session authorization</label><br /> 
     84 
     85<p class="hint">This increases security but can cause sudden logouts when someone uses a proxy with changeing IPs.</p> 
     86</dd> 
     87 
     88<dt class="propname">des_key</dt> 
     89<dd> 
     90<?php 
     91 
     92$input_deskey = new html_inputfield(array('name' => '_des_key', 'size' => 30, 'id' => "cfgdeskey")); 
     93echo $input_deskey->show($RCI->getprop('des_key')); 
     94 
     95?> 
     96<div>This key is used to encrypt the users imap password before storing in the session record</div> 
     97<p class="hint">It's a random generated string to ensure that every installation has it's own key. 
     98If you enter it manually please provide a string of exactly 24 chars.</p> 
     99</dd> 
     100 
     101<dt class="propname">enable_caching</dt> 
     102<dd> 
     103<?php 
     104 
     105$check_caching = new html_checkbox(array('name' => '_enable_caching', 'id' => "cfgcache")); 
     106echo $check_caching->show(intval($RCI->getprop('enable_caching')), array('value' => 1)); 
     107 
     108?> 
     109<label for="cfgcache">Cache messages in local database</label><br /> 
     110</dd> 
     111 
     112<dt class="propname">enable_spellcheck</dt> 
     113<dd> 
     114<?php 
     115 
     116$check_caching = new html_checkbox(array('name' => '_enable_spellcheck', 'id' => "cfgspellcheck")); 
     117echo $check_caching->show(intval($RCI->getprop('enable_spellcheck')), array('value' => 1)); 
     118 
     119?> 
     120<label for="cfgspellcheck">Make use of the built-in spell checker</label><br /> 
     121 
     122<p class="hint">It is based on GoogieSpell what implies that the message content will be sent to Google in order to check the spelling.</p> 
     123</dd> 
     124 
     125</dl> 
     126</fieldset> 
     127 
     128<fieldset> 
     129<legend>Logging & Debugging</legend> 
     130<dl class="loggingblock"> 
     131 
     132<dt class="propname">debug_level</dt> 
     133<dd> 
     134<?php 
     135 
    55136$value = $RCI->getprop('debug_level'); 
    56137$check_debug = new html_checkbox(array('name' => '_debug_level[]')); 
     
    59140 
    60141echo $check_debug->show(($value & 4) ? 4 : 0, array('value' => 4, 'id' => 'cfgdebug4')); 
    61 echo '<label for="cfgdebug4">Display errors</label><br />'; 
     142echo '<label for="cfgdebug4">Print errors (to the browser)</label><br />'; 
    62143 
    63144echo $check_debug->show(($value & 8) ? 8 : 0, array('value' => 8, 'id' => 'cfgdebug8')); 
    64 echo '<label for="cfgdebug8">Verbose display</label><br />'; 
    65 */ 
    66 ?> 
    67 </dd> 
    68 --> 
    69  
    70 <dt class="propname">product_name</dt> 
    71 <dd> 
    72 <?php 
    73  
    74 $input_prodname = new html_inputfield(array('name' => '_product_name', 'size' => 30, 'id' => "cfgprodname")); 
    75 echo $input_prodname->show($RCI->getprop('product_name')); 
    76  
    77 ?> 
    78 <div>The name of your service (used to compose page titles)</div> 
    79 </dd> 
    80  
    81 <dt class="propname">temp_dir</dt> 
    82 <dd> 
    83 <?php 
    84  
    85 $input_tempdir = new html_inputfield(array('name' => '_temp_dir', 'size' => 30, 'id' => "cfgtempdir")); 
    86 echo $input_tempdir->show($RCI->getprop('temp_dir')); 
    87  
    88 ?> 
    89 <div>Use this folder to store temp files (must be writebale for webserver)</div> 
     145echo '<label for="cfgdebug8">Verbose display (enables debug console)</label><br />'; 
     146 
     147?> 
     148</dd> 
     149 
     150<dt class="propname">log_driver</dt> 
     151<dd> 
     152<?php 
     153 
     154$select_log_driver = new html_select(array('name' => '_log_driver', 'id' => "cfglogdriver")); 
     155$select_log_driver->add(array('file', 'syslog'), array('file', 'syslog')); 
     156echo $select_log_driver->show($RCI->getprop('log_driver', 'file')); 
     157 
     158?> 
     159<div>How to do logging? 'file' - write to files in the log directory, 'syslog' - use the syslog facility.</div> 
    90160</dd> 
    91161 
     
    98168 
    99169?> 
    100 <div>Use this folder to store log files (must be writebale for webserver)</div> 
    101 </dd> 
    102  
    103 <dt class="propname">ip_check</dt> 
    104 <dd> 
    105 <?php 
    106  
    107 $check_ipcheck = new html_checkbox(array('name' => '_ip_check', 'id' => "cfgipcheck")); 
    108 echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)); 
    109  
    110 ?> 
    111 <label for="cfgipcheck">Check client IP in session authorization</label><br /> 
    112  
    113 <p class="hint">This increases security but can cause sudden logouts when someone uses a proxy with changeing IPs.</p> 
    114 </dd> 
    115  
    116 <dt class="propname">des_key</dt> 
    117 <dd> 
    118 <?php 
    119  
    120 $input_deskey = new html_inputfield(array('name' => '_des_key', 'size' => 30, 'id' => "cfgdeskey")); 
    121 echo $input_deskey->show($RCI->getprop('des_key')); 
    122  
    123 ?> 
    124 <div>This key is used to encrypt the users imap password before storing in the session record</div> 
    125 <p class="hint">It's a random generated string to ensure that every installation has it's own key. 
    126 If you enter it manually please provide a string of exactly 24 chars.</p> 
    127 </dd> 
    128  
    129 <dt class="propname">enable_caching</dt> 
    130 <dd> 
    131 <?php 
    132  
    133 $check_caching = new html_checkbox(array('name' => '_enable_caching', 'id' => "cfgcache")); 
    134 echo $check_caching->show(intval($RCI->getprop('enable_caching')), array('value' => 1)); 
    135  
    136 ?> 
    137 <label for="cfgcache">Cache messages in local database</label><br /> 
    138 </dd> 
    139  
    140 <dt class="propname">enable_spellcheck</dt> 
    141 <dd> 
    142 <?php 
    143  
    144 $check_caching = new html_checkbox(array('name' => '_enable_spellcheck', 'id' => "cfgspellcheck")); 
    145 echo $check_caching->show(intval($RCI->getprop('enable_spellcheck')), array('value' => 1)); 
    146  
    147 ?> 
    148 <label for="cfgspellcheck">Make use of the built-in spell checker</label><br /> 
    149  
    150 <p class="hint">It is based on GoogieSpell what implies that the message content will be sent to Google in order to check the spelling.</p> 
    151 </dd> 
     170<div>Use this folder to store log files (must be writebale for webserver). Note that this only applies if you are using the 'file' log_driver.</div> 
     171</dd> 
     172 
     173<dt class="propname">syslog_id</dt> 
     174<dd> 
     175<?php 
     176 
     177$input_syslogid = new html_inputfield(array('name' => '_syslog_id', 'size' => 30, 'id' => "cfgsyslogid")); 
     178echo $input_syslogid->show($RCI->getprop('syslog_id', 'roundcube')); 
     179 
     180?> 
     181<div>What ID to use when logging with syslog. Note that this only applies if you are using the 'syslog' log_driver.</div> 
     182</dd> 
     183 
     184<dt class="propname">syslog_facility</dt> 
     185<dd> 
     186<?php 
     187 
     188$input_syslogfacility = new html_select(array('name' => '_syslog_facility', 'id' => "cfgsyslogfacility")); 
     189$input_syslogfacility->add('user-level messages', LOG_USER); 
     190$input_syslogfacility->add('mail subsystem', LOG_MAIL); 
     191$input_syslogfacility->add('local level 0', LOG_LOCAL0); 
     192$input_syslogfacility->add('local level 1', LOG_LOCAL1); 
     193$input_syslogfacility->add('local level 2', LOG_LOCAL2); 
     194$input_syslogfacility->add('local level 3', LOG_LOCAL3); 
     195$input_syslogfacility->add('local level 4', LOG_LOCAL4); 
     196$input_syslogfacility->add('local level 5', LOG_LOCAL5); 
     197$input_syslogfacility->add('local level 6', LOG_LOCAL6); 
     198$input_syslogfacility->add('local level 7', LOG_LOCAL7); 
     199echo $input_syslogfacility->show($RCI->getprop('syslog_facility'), LOG_USER); 
     200 
     201?> 
     202<div>What ID to use when logging with syslog.  Note that this only applies if you are using the 'syslog' log_driver.</div> 
     203</dd> 
     204 
     205 
     206 
    152207 
    153208</dl> 
    154209</fieldset> 
     210 
    155211 
    156212<fieldset> 
     
    379435 
    380436?> 
    381 <label for="cfgsmtplog">Log sent messages in <tt>logs/sendmail</tt></label><br /> 
     437<label for="cfgsmtplog">Log sent messages in <tt>{log_dir}/sendmail</tt> or to syslog.</label><br /> 
    382438</dd> 
    383439 
  • trunk/roundcubemail/installer/rcube_install.php

    r1354 r1683  
    101101  function getprop($name, $default = '') 
    102102  { 
    103     $value = $this->is_post && (isset($_POST["_$name"]) || $this->config_props[$name]) ? $_POST["_$name"] : $this->config[$name]; 
     103    $value = $this->config[$name]; 
    104104     
    105105    if ($name == 'des_key' && !$this->configured && !isset($_REQUEST["_$name"])) 
     
    128128       
    129129      // convert some form data 
    130       if ($prop == 'debug_level' && is_array($value)) { 
     130      if ($prop == 'debug_level') { 
    131131        $val = 0; 
    132         foreach ($value as $i => $dbgval) 
    133           $val += intval($dbgval); 
    134         $value = $val; 
     132        if (isset($value)) 
     133          foreach ($value as $dbgval) 
     134            $val += intval($dbgval); 
     135        $value = $val; 
    135136      } 
    136137      else if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) { 
     
    169170      if ($value == $default) 
    170171        continue; 
    171        
     172 
     173      // save change 
     174      $this->config[$prop] = $value; 
     175 
    172176      // replace the matching line in config file 
    173177      $out = preg_replace( 
  • trunk/roundcubemail/installer/test.php

    r1681 r1683  
    3636if ($RCI->configured) { 
    3737    $pass = false; 
    38     foreach (array($RCI->config['temp_dir'],$RCI->config['log_dir']) as $dir) { 
     38 
     39    $dirs[] = $RCI->config['temp_dir']; 
     40    if($RCI->config['log_driver'] != 'syslog') 
     41      $dirs[] = $RCI->config['log_dir']; 
     42 
     43    foreach ($dirs as $dir) { 
    3944        $dirpath = $dir{0} == '/' ? $dir : INSTALL_PATH . $dir; 
    4045        if (is_writable(realpath($dirpath))) { 
  • trunk/roundcubemail/program/include/bugs.inc

    r1291 r1683  
    8585       
    8686    // try to open specific log file for writing 
    87     if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a')) 
     87    if ($CONFIG['log_driver'] == 'syslog') 
    8888    { 
     89      syslog(LOG_ERR, $log_entry); 
     90    } 
     91    else if ($fp = @fopen($CONFIG['log_dir'].'/errors', 'a')) 
     92    { 
     93      // log_driver == 'file' is the default, assumed here. 
    8994      fwrite($fp, $log_entry); 
    9095      fclose($fp); 
  • trunk/roundcubemail/program/include/main.inc

    r1681 r1683  
    829829                 $line); 
    830830                  
    831   if (empty($CONFIG['log_dir'])) 
    832     $CONFIG['log_dir'] = INSTALL_PATH.'logs'; 
     831  if ($CONFIG['log_driver'] == 'syslog') { 
     832    if ($name == 'errors') 
     833      $prio = LOG_ERR; 
     834    else 
     835      $prio = LOG_INFO; 
     836    syslog($prio, $log_entry); 
     837  } else { 
     838    // log_driver == 'file' is assumed here 
     839    if (empty($CONFIG['log_dir'])) 
     840      $CONFIG['log_dir'] = INSTALL_PATH.'logs'; 
    833841       
    834   // try to open specific log file for writing 
    835   if ($fp = @fopen($CONFIG['log_dir'].'/'.$name, 'a'))     
    836     { 
    837     fwrite($fp, $log_entry); 
    838     fclose($fp); 
    839     } 
    840   } 
     842    // try to open specific log file for writing 
     843    if ($fp = @fopen($CONFIG['log_dir'].'/'.$name, 'a')) { 
     844      fwrite($fp, $log_entry); 
     845      fclose($fp); 
     846    } 
     847  } 
     848} 
    841849 
    842850 
  • trunk/roundcubemail/program/include/rcmail.php

    r1681 r1683  
    8383    $config_all = $this->config->all(); 
    8484 
     85    // initialize syslog 
     86    if ($this->config->get('log_driver') == 'syslog') { 
     87      $syslog_id = $this->config->get('syslog_id', 'roundcube'); 
     88      $syslog_facility = $this->config->get('syslog_facility', LOG_USER); 
     89      openlog($syslog_id, LOG_ODELAY, $syslog_facility); 
     90    } 
     91                                 
    8592    // set task and action properties 
    8693    $this->set_task(strip_quotes(get_input_value('_task', RCUBE_INPUT_GPC))); 
     
    111118      $_SESSION['temp'] = true; 
    112119    } 
    113  
    114120 
    115121    // create user object 
  • trunk/roundcubemail/program/include/rcube_config.php

    r1614 r1683  
    8383    if ($this->prop['debug_level'] & 1) { 
    8484      ini_set('log_errors', 1); 
    85       ini_set('error_log', $this->prop['log_dir'] . '/errors'); 
     85 
     86      if ($this->prop['log_driver'] == 'syslog') { 
     87        ini_set('error_log', 'syslog'); 
     88      } else { 
     89        ini_set('error_log', $this->prop['log_dir'].'/errors'); 
     90      } 
    8691    } 
    8792    if ($this->prop['debug_level'] & 4) { 
  • trunk/roundcubemail/program/steps/mail/sendmail.inc

    r1644 r1683  
    421421  if ($CONFIG['smtp_log']) 
    422422    { 
    423     $log_entry = sprintf( 
     423    write_log('sendmail', sprintf( 
    424424      "[%s] User: %d on %s; Message for %s; %s\n", 
    425425      date("d-M-Y H:i:s O", mktime()), 
     
    427427      $_SERVER['REMOTE_ADDR'], 
    428428      $mailto, 
    429       !empty($smtp_response) ? join('; ', $smtp_response) : ''); 
    430  
    431     if ($fp = @fopen($CONFIG['log_dir'].'/sendmail', 'a')) 
    432       { 
    433       fwrite($fp, $log_entry); 
    434       fclose($fp); 
    435       } 
     429      !empty($smtp_response) ? join('; ', $smtp_response) : '')); 
    436430    } 
    437431 
Note: See TracChangeset for help on using the changeset viewer.