From 653c59cef8f1e684aef2f9aa17cd181c387d47bc Mon Sep 17 00:00:00 2001 From: Baldur Rensch Date: Fri, 25 May 2012 10:04:35 -0700 Subject: [PATCH] Added switch to error log 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. --- src/class.seostats.config.php | 3 +++ src/class.seostats.php | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/class.seostats.config.php b/src/class.seostats.config.php index 119c68a5..dbe623e4 100644 --- a/src/class.seostats.config.php +++ b/src/class.seostats.config.php @@ -39,4 +39,7 @@ 'member-881a55bcfb'); define('SEOMOZ_SECRET_KEY', '7145d56a1279285be92e6e4875bba8ee'); + + define('ERR_LOG_ENABLED', true); + define('ERR_LOG_PATH', 'errlog.txt'); ?> diff --git a/src/class.seostats.php b/src/class.seostats.php index c742c7a1..1eb7ed13 100644 --- a/src/class.seostats.php +++ b/src/class.seostats.php @@ -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); + } } /**