topical media & game development

talk show tell print

professional-php-11-newLoggerPGSQLClassTest.php / php



  <?php
  
  cfg['LOGGER_LEVEL'] = LOGGER_INFO;
  
  Logger::register('app', 'pgsql://steve@localhost/mydb?table=logdata');
  
  log = Logger::getInstance('app');
  
  if(isset(_GET['fooid'])) {
    
    //not written to the log - the log level is too high
    log->logMessage('A fooid is present', LOGGER_DEBUG);
    
    //LOG_INFO is the default, so this would get printed
    log->logMessage('The value of fooid is ' .  _GET['fooid']);
    
  } else {
    
    //This will also be written and includes a module name
    log->logMessage('No fooid passed from ' . _SERVER['HTTP_REFERER'], 
                     LOGGER_CRITICAL,
                     "Foo Module");
    
    throw new Exception('No foo id!');
  }
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.