3 require_once DOL_DOCUMENT_ROOT.
'/core/modules/syslog/logHandler.php';
10 public $code =
'file';
22 return $langs->trans(
'File');
44 return $langs->trans(
'YouCanUseDOL_DATA_ROOT');
55 return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_FILE) ? 1 : 0;
69 'name' => $langs->trans(
'SyslogFilename'),
70 'constant' =>
'SYSLOG_FILE',
71 'default' =>
'DOL_DATA_ROOT/dolibarr.log',
90 if (file_exists($filename) && is_writable($filename))
93 }
else $errors[] = $langs->trans(
"ErrorFailedToOpenFile", $filename);
108 if (empty($conf->global->SYSLOG_FILE)) $tmp = DOL_DATA_ROOT.
'/dolibarr.log';
109 else $tmp = str_replace(
'DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE);
111 if (!empty($conf->global->SYSLOG_FILE_ONEPERSESSION))
113 if ($conf->global->SYSLOG_FILE_ONEPERSESSION == 1)
115 $suffixinfilename .=
'_'.session_name();
117 if ($conf->global->SYSLOG_FILE_ONEPERSESSION == 2)
119 $suffixinfilename .=
'_'.session_name().
'_'.
$_SERVER[
"REMOTE_ADDR"];
123 return $suffixinfilename ?preg_replace(
'/\.log$/i', $suffixinfilename.
'.log', $tmp) : $tmp;
133 public function export($content, $suffixinfilename =
'')
135 global $conf, $dolibarr_main_prod;
137 if (!empty($conf->global->MAIN_SYSLOG_DISABLE_FILE))
return;
142 if (defined(
'SYSLOG_FILE_NO_ERROR')) $filefd = @fopen($logfile,
'a+');
143 else $filefd = fopen($logfile,
'a+');
147 if (!defined(
'SYSLOG_FILE_NO_ERROR') || !constant(
'SYSLOG_FILE_NO_ERROR'))
151 print 'Failed to open log file '.($dolibarr_main_prod ?basename($logfile) : $logfile);
155 LOG_EMERG =>
'EMERG',
156 LOG_ALERT =>
'ALERT',
159 LOG_WARNING =>
'WARNING',
160 LOG_NOTICE =>
'NOTICE',
166 if (!empty($conf->global->MAIN_SYSLOG_SHOW_DELAY))
168 $now = microtime(
true);
169 $delay =
" ".sprintf(
"%05.3f", $this->lastTime != 0 ? $now - $this->lastTime : 0);
170 $this->lastTime = $now;
173 $message = strftime(
"%Y-%m-%d %H:%M:%S", time()).$delay.
" ".sprintf(
"%-7s", $logLevels[$content[
'level']]).
" ".sprintf(
"%-15s", $content[
'ip']).
" ".($this->ident > 0 ?str_pad(
'', $this->ident,
' ') :
'').$content[
'message'];
174 fwrite($filefd, $message.
"\n");
176 @chmod($logfile, octdec(empty($conf->global->MAIN_UMASK) ?
'0664' : $conf->global->MAIN_UMASK));
getName()
Return name of logger.
getVersion()
Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development')
Class to manage logging to a file.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
configure()
Return array of configuration data.
print $_SERVER["PHP_SELF"]
Edit parameters.
getInfo()
Content of the info tooltip.
print
Draft customers invoices.
export($content, $suffixinfilename= '')
Export the message.
getFilename($suffixinfilename= '')
Return the parsed logfile path.
isActive()
Is the module active ?
Parent class for log handlers.
checkConfiguration()
Return if configuration is valid.