Archive for the ‘PHP’ Category

Firephp log appender for log4php

Sunday, August 30th, 2009

I’ve been using Zend Framework lately on a couple of projects, but I’m not very fond of the framework’s logger (Zend_Log).  There are some nice features of log4php (daily log, rolling log, tcp logger, etc.) that make it by far the best logger out there (and the project has been restarted after a few years of inactivity, with a nice rewrite for PHP5 (svn only at this point)).  I decided to create an appender for Firephp to use during development.  For autoloading, you will need to add it to the class list in Logger.php.

/** Zend_Wildfire_Plugin_FirePhp */
require_once 'Zend/Wildfire/Plugin/FirePhp.php';
 
class LoggerAppenderFirephp extends LoggerAppender {
 
	public function __construct($name = '') {
		parent::__construct($name);
		$this->requiresLayout = false;
	}
 
	public function __destruct() {
       $this->close();
   	}
 
	public function activateOptions() {
		$this->closed = false;
	}
 
	public function close() {
		$this->closed = true;
	}
 
	public function append($event) {
			$level = $event->getLevel();
			$tl = strtolower($level->toString());
			switch($tl) {
				case 'debug':
					$log_level = Zend_Wildfire_Plugin_FirePhp::LOG;
					break;
				case 'info':
					$log_level = Zend_Wildfire_Plugin_FirePhp::INFO;
					break;
				case 'warn':
					$log_level = Zend_Wildfire_Plugin_FirePhp::WARN;
					break;
				case 'error':
					$log_level = Zend_Wildfire_Plugin_FirePhp::ERROR;
					break;
				case 'fatal':
					$log_level = Zend_Wildfire_Plugin_FirePhp::ERROR;
					break;
				default:
					$log_level = Zend_Wildfire_Plugin_FirePhp::INFO;
			}
	        Zend_Wildfire_Plugin_FirePhp::getInstance()->send('[' . $level->toString() . '] - ' . $event->getRenderedMessage(),
	                                                          null,
	                                                          $log_level,
	                                                          array('traceOffset'=>6));
	}
}

Server Status for the iPhone

Monday, December 22nd, 2008

I have completed RC1 of the Server Status web application for the iPhone.  I plan on forking the code for another project that will include portions of the SliceHost API for server management.  Download, and details to follow soon, but for now here are a couple of screen shots:

Download

About Binary Signal

A small web application and software development company located in Portland, Oregon.

Small Business

As a small business owner myself, I am committed to supporting small businesses and using local resources when needed. If you are a small business in the Portland metro area, ask me about a discounted hourly rate.