2011-04-20 06:46:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Logging {
|
|
|
|
|
|
|
|
private static $_logger;
|
|
|
|
private static $_path;
|
|
|
|
|
|
|
|
public static function getLogger(){
|
|
|
|
if (!isset(self::$logger)) {
|
|
|
|
$writer = new Zend_Log_Writer_Stream(self::$_path);
|
|
|
|
self::$_logger = new Zend_Log($writer);
|
|
|
|
}
|
|
|
|
return self::$_logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setLogPath($path){
|
|
|
|
self::$_path = $path;
|
|
|
|
}
|
2011-08-15 22:40:24 +02:00
|
|
|
|
2012-04-13 22:50:54 +02:00
|
|
|
public static function toString($p_msg){
|
2012-04-16 23:29:02 +02:00
|
|
|
if (is_array($p_msg) || is_object($p_msg)){
|
2012-04-13 22:50:54 +02:00
|
|
|
return print_r($p_msg, true);
|
|
|
|
} else {
|
|
|
|
return $p_msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-15 22:40:24 +02:00
|
|
|
public static function log($p_msg){
|
|
|
|
$logger = self::getLogger();
|
2012-04-13 22:50:54 +02:00
|
|
|
$logger->info(self::toString($p_msg));
|
2011-08-15 22:40:24 +02:00
|
|
|
}
|
2011-12-02 22:22:54 +01:00
|
|
|
|
|
|
|
public static function debug($p_msg){
|
2012-03-13 15:21:01 +01:00
|
|
|
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development"){
|
2011-12-02 22:22:54 +01:00
|
|
|
$logger = self::getLogger();
|
2012-04-13 22:50:54 +02:00
|
|
|
$logger->debug(self::toString($p_msg));
|
2011-12-02 22:22:54 +01:00
|
|
|
}
|
|
|
|
}
|
2011-04-20 06:46:03 +02:00
|
|
|
}
|