Difference between revisions of "JLog/addEntry"
From Joomla! Documentation
< API15:JLog
(New page:
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Description:JLog/addEntry}}
===Synt...) |
m (preparing for archive only) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 72: | Line 71: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
− | + | === Code Examples === | |
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=addEntry | category=addEntry | ||
category=JLog | category=JLog | ||
− | + | namespace=CodeExample | |
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API15]] |
Latest revision as of 19:56, 24 March 2017
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
addEntry($entry)
Parameter Name | Default Value | Description |
---|---|---|
$entry |
Defined in[edit]
libraries/joomla/error/log.php
Importing[edit]
jimport( 'joomla.error.log' );
Source Body[edit]
function addEntry($entry)
{
// Set some default field values if not already set.
$date =& JFactory::getDate();
if (!isset ($entry['date'])) {
$entry['date'] = $date->toFormat("%Y-%m-%d");
}
if (!isset ($entry['time'])) {
$entry['time'] = $date->toFormat("%H:%M:%S");
}
if (!isset ($entry['c-ip'])) {
$entry['c-ip'] = $_SERVER['REMOTE_ADDR'];
}
// Ensure that the log entry keys are all uppercase
$entry = array_change_key_case($entry, CASE_UPPER);
// Find all fields in the format string
$fields = array ();
$regex = "/{(.*?)}/i";
preg_match_all($regex, $this->_format, $fields);
// Fill in the field data
$line = $this->_format;
for ($i = 0; $i < count($fields[0]); $i++)
{
$line = str_replace($fields[0][$i], (isset ($entry[$fields[1][$i]])) ? $entry[$fields[1][$i]] : "-", $line);
}
// Write the log entry line
if ($this->_openLog())
{
if (!fputs($this->_file, "\n" . $line)) {
return false;
}
} else {
return false;
}
return true;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]