PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Ivan Stojmenovic   Log-class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example how to use
Class: Log-class
Log activity messages to files
Author: By
Last change:
Date: 12 years ago
Size: 1,648 bytes
 

Contents

Class file image Download

 First configure logger class in constructor or include your config file.

 *Set directory log patch
 *Set date format
 *Set file extension
 *Set file prefix

 Nubers of error levels:

 1 = DEBUG
 2 = ERROR
 3 = INFO
 4 = NOTICE


<?php

// Initialize class

$log = new Log;

 
// or

Log::[method];

// If u have autoload function in your application u dont need initialize // Log class.


// Example DEBUG message

class Controller {

      public function
__construct() {

          
log_message('debug','Controller class initialized');
         
          
// or
  
          
Log::log_message('debug','Controller class initialized');

          
// you can use numeric level ID

          
log_message(1,'Controller expect string');
    
     }

}

// Example ERROR

class Controller {

      public function
__construct($param) {

           if(!
is_string($param) && isset($param)) {

              
log_message('error','Controller expect string');
                
//or
              
Log::log_message('error','Controller expect string');

               
// you can use numeric level ID

              
log_message(2,'Controller expect string');

           }
    
     }

}


// Example INFO

class Controller {

      public function
__construct() {
         

              
log_message('info','Reconnection with database is successifly');
           
     }

}


// Example Notice

class Controller {

      public function
__construct() {
         

              
log_message('notice','Connection loss!');
           
     }

}