R
ragtek
Guest
I've created a Logger Class, to create Logentries while i'm developing Add-ons.
It's a nice, little helper
Usage:
or direct in the add-on i'm using this, to make sure the users have no problems, if they don't have the class
It's based on the Zend Logger, so you can also use FireBug or Zend Monitor and other providen methods.
For more infos check http://framework.zend.com/manual/de/zend.log.writers.html
It's a nice, little helper
PHP:
<?php
/**
* Ragtek Logger, creates a logfile which can be used to log messages,
* and other "important stuff, it's nice for debugging;)
*
* @copyright ragtek
* @version 1.0.0
* @package Ragtek/Helper
*/
class Ragtek_Helper_Log
{
/**
* @var Zend_Log
*/
private $logger = null;
/**
* @var Zend_Log_Writer_Stream
*/
private $writer = null;
static private $instance = null;
public static function getInstance()
{
if (!self::$instance)
{
self::$instance = new self;
}
return self::$instance;
}
public function __construct($path = '')
{
if ($path == '')
{
$path = XenForo_Autoloader::getInstance()->getRootDir() . '\Ragtek\log.txt';
}
$this->writer = new Zend_Log_Writer_Stream($path);
$this->logger = new Zend_Log($this->writer);
}
public function log($message, $priority = Zend_Log::INFO)
{
$this->logger->log($message, $priority);
}
}
Usage:
PHP:
Ragtek_Helper_Log::getInstance()->log('created contact thread');
PHP:
if (XenForo_Application::debugMode() AND class_exists('Ragtek_Helper_Log'))
{
Ragtek_Helper_Log::getInstance()->log('created contact thread');
}
For more infos check http://framework.zend.com/manual/de/zend.log.writers.html