allow to set a higher account-import log-level then "info"

This commit is contained in:
ralf 2023-08-15 16:02:54 +02:00
parent 2faa699325
commit 303dc2bc70
2 changed files with 19 additions and 11 deletions

View File

@ -157,22 +157,23 @@ class Import
call_user_func($this->_logger, $message, $level);
}
$loglevel = $GLOBALS['egw_info']['server']['account_import_loglevel'] ?? 'info';
if ($loglevel === 'info' && in_array($level, ['debug', 'detail']) ||
$loglevel === 'detail' && $level === 'debug')
{
return;
}
// log to file too
$log = $GLOBALS['egw_info']['server']['files_dir'].'/'.self::LOG_FILE;
if (!file_exists($dir=dirname($log)) && !mkdir($dir) || !is_dir($dir) ||
!($fp = fopen($log, 'a+')))
{
if (!in_array($level, ['debug', 'detail']))
{
error_log(__METHOD__.' '.strtoupper($level).' '.$message);
}
error_log(__METHOD__.' '.strtoupper($level).' '.$message);
}
else
{
if ($this->_logger || !in_array($level, ['debug', 'detail']))
{
fwrite($fp, date('Y-m-d H:i:s O').' '.strtoupper($level).' '.$message."\n");
}
}
if (!empty($fp)) fclose($fp);
}
@ -908,7 +909,7 @@ class Import
$import = new self();
$import->logger(date('Y-m-d H:i:s O').' LDAP account import started', 'info');
$import->run(false);
$import->logger(date('Y-m-d H:i:s O').' LDAP account import finished'.(!empty($fp)?"\n":''), 'info');
$import->logger(date('Y-m-d H:i:s O').' LDAP account import finished', 'info');
}
catch (\InvalidArgumentException $e) {
_egw_log_exception($e);
@ -918,7 +919,7 @@ class Import
}
catch (\Exception $e) {
_egw_log_exception($e);
$import->logger('Error: '.$e->getMessage());
$import->logger('Error: '.$e->getMessage(), 'fatal');
}
}

View File

@ -129,6 +129,7 @@
<select name="newsettings[auth_type]">
{hook_auth_types}
</select>
<input type="hidden" value="" name="newsettings[auth_log]"/>
<label><input type="checkbox" value="True" {checked_auth_log_True} name="newsettings[auth_log]"/>
{lang_Enable_logging_of_authentication_to_files-directory}: auth.log</label>
</td>
@ -177,6 +178,7 @@
<tr class="row_off">
<td>{lang_Fallback_Authentication}:</td>
<td>
<input type="hidden" value="" name="newsettings[auth_fallback]"/>
<label><input type="checkbox" value="True" {checked_auth_fallback_True} name="newsettings[auth_fallback]"/>
{lang_If_primary_authentication_is_NOT_successful_fall_back_to_passwords_synced_into_account-storage}</label>
</td>
@ -495,7 +497,7 @@
<option value="deactivate" {selected_account_import_delete_deactivate}>{lang_Deactivate_user}</option>
<option value="no" {selected_account_import_delete_no}>{lang_Do_NOT_check_for_deleted_user}</option>
</select>
<br/><i>Deleting or disabling no longer existing accounts works currently only by using manual inital import!</i>
<br/><i>Deleting or disabling no longer existing accounts works currently only by using manual initial import!</i>
</td>
</tr>
<tr class="row_off">
@ -505,7 +507,12 @@
<input type="number" name="newsettings[account_import_frequency]" style="width: 3em" value="{value_account_import_frequency}"/>
{lang_hours_at}
<input type="time" name="newsettings[account_import_time]" value="{value_account_import_time}"/>
{lang_logs_to}: {value_files_dir}/setup/account-import.log
{lang_Log-Level}: <select name="newsettings[account_import_loglevel]">
<option value="info" {selected_account_import_loglevel_info}>Info</option>
<option value="detail" {selected_account_import_loglevel_detail}>Detail</option>
<option value="debug" {selected_account_import_loglevel_debug}>Debug</option>
</select>
<br/>{lang_logs_to}: {value_files_dir}/setup/account-import.log
</td>
</tr>
<tr class="row_on">