Aside from the missing new-lines (which is most likely down to Notepad's "features"), you could use the error_log
function in PHP. Using them you don't have to worry about the overhead of opening and closing file handles as it's all taken care of for you:
/**
* logMessage
* @param string $message
* @param string $filename
* @param resource $logHandle
*/
function logMessage($message=null, $filename=null, $logHandle=null)
{
if (!is_null($filename))
{
$logMsg=date('Y/m/d H:i:s').": {$message}\n";
error_log($logMsg, 3, $filename);
}
if (is_object($logHandle))
{
try
{
$errorPS=$logHandle->prepare("insert into ".LOG_TABLE." (insertDateTime,logText) values (now(),:message)");
$errorPS->bindParam(':message', $message, PDO::PARAM_STR);
$errorPS->execute();
} catch (PDOException $e)
{
logError($e->getMessage(), ERROR_LOG);
}
}
}
/**
* logError
* @param string $message
* @param string $filename
* @param resource $logHandle
*/
function logError($message=null, $filename=null, $logHandle=null)
{
if (!is_null($message))
{
logMessage("***ERROR*** {$message}", $filename, $logHandle);
}
}
The above functions are ones that I wrote for custom logging to a file (and, alternatively, a database table)
Hope this helps