PHP Classes
Icontem

File: index.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marius Zadara  >  Logger  >  index.php  
File: index.php
Role: Example script
Content type: text/plain
Description: Logger example
Class: Logger
Filter and export data of application events
 

Contents

Class file image Download
<?php

/**
 * Demo script to put the Logger at work.
 * In this script, a handler (with it's exporter) will be added to the logger
 * and a event will be generated to see if it caught.
 * 
 * @author Marius Zadara <marius@zadara.org>
 * @category org.zadara.marius.logger.exceptions
 * @copyright (C) 2008 Marius Zadara <marius@zadara.org>
 * @license GNU GPL
 * @package org.zadara.marius.logger
 */


// add all the program's prerequisites
require '_interfaces/addInterfaces.php';
require 
'_exceptions/addExceptions.php';
require 
'_constants/addConstants.php';
require 
'_classes/addClasses.php';



// EVENT EXPORTERS DEFINITIONS ////////////////////////////////////////////////////////////////////

// event exporter to the console
// this exporter will be used in both of the handlers
$consoleExporter = new ConsoleExporter();



// EVENT HANDLERS DEFINITIONS /////////////////////////////////////////////////////////////////////

// first event handler - this one will accept all the events that will pass throught the logger 
$allEventHandler = new AllEventsHandler();

// second event handler - this one will accept only high levels events 
$highEventLevelHandler = new HighEventLevelHandler();



// EVENT EXPORTERS TO HANDLERS ASSOCIATIONS ///////////////////////////////////////////////////////

// associate the exporter to the first and second exporter
// this is done for this demo convenience, but is not mandatory - each handler can have its custom exporter
$allEventHandler->setExporter($consoleExporter);
$highEventLevelHandler->setExporter($consoleExporter);


// LOGGER DEFINITION //////////////////////////////////////////////////////////////////////////////

// instanciate the main logger class
$logger = new Logger();

// register all the handlers previously defined
$logger->registerHandler($allEventHandler);
$logger->registerHandler($highEventLevelHandler);


// simulate the info level event
// this event will be caught by the first handler ($allEventHandler) because
// this handler accepts all the events, no matter its definition
$logger->info("My first event"Sources::$HOMECategories::$APPLICATION"Info based event");

// simulate the sever level event
// this event will be accepted by both of the handlers:
// > the first because it accepts all the events
// > the second because the event levels matches the required
$logger->severe("My second event"Sources::$HOMECategories::$APPLICATION"Severe event");


?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products