[TYPO3-english] Write to log within eID extension

Simon Strandgaard simon at bee3.com
Thu Apr 22 10:40:10 CEST 2010


On Thu, Apr 22, 2010 at 10:04 AM, Simon Strandgaard <simon at bee3.com> wrote:

> I'm on a server where I cannot tail -f the php_error.log. I interested in
> writing to the log module in order to debug my code.
>

[snip]

> Alternative ways to debug it?
>
>

solution: I have put together some code that appends messages to a file.

$this->writelog('hello world');



function writelog($message) {
$t = time();
$mt_array = explode(" ", microtime());
$mt = $mt_array[1];
$timestamp = strftime("%Y_%m_%d_%H_%M_%S", $t) . '_' . $mt;
$this->writelog_inner($timestamp . ' ' . $message . "\n");
}

function writelog_inner($message) {
$path = PATH_site . 'fileadmin/myext__eid.log';
$f = fopen($path, 'a') or error_log("can't open file: " . $path . "
 message: " . $message);
fwrite($f, $message);
fclose($f);
}


-- 
Best regards
Simon Strandgaard


More information about the TYPO3-english mailing list