Skip to content

Commit

Permalink
Added switch to error log
Browse files Browse the repository at this point in the history
This makes it possible to disable the error log and set the path to the
error log file. Ideally this would be implemented with a logging
interface to allow to use third party loggers.
  • Loading branch information
Baldur Rensch committed May 25, 2012
1 parent 7e10cf8 commit 653c59c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/class.seostats.config.php
Expand Up @@ -39,4 +39,7 @@
'member-881a55bcfb');
define('SEOMOZ_SECRET_KEY',
'7145d56a1279285be92e6e4875bba8ee');

define('ERR_LOG_ENABLED', true);
define('ERR_LOG_PATH', 'errlog.txt');
?>
16 changes: 11 additions & 5 deletions src/class.seostats.php
Expand Up @@ -128,13 +128,19 @@ public function __construct($url)
}
}

/**
* Logs an error to the error log file
*
* @param String $errtxt The error message to log
*/
function errlogtxt($errtxt)
{
$fp = fopen('errlog.txt','a+'); //ouvrir le fichier
$newerr = date('Y-m-d\TH:i:sP') .' : ' . $errtxt."\r\n"; //creation du texte de l'erreur
fwrite($fp,$newerr); //edition du fichier texte
fclose($fp); //fermeture du fichier texte
echo $newerr;
if (ERR_LOG_ENABLED) {
$fp = fopen(ERR_LOG_PATH,'a+');
$newerr = date('Y-m-d\TH:i:sP') .' : ' . $errtxt."\r\n";
fwrite($fp,$newerr);
fclose($fp);
}
}

/**
Expand Down

0 comments on commit 653c59c

Please sign in to comment.