public static function quickLogCaller()
 {
     EasyLogger::instantiate();
     $bt = debug_backtrace();
     $bt = array_shift($bt);
     $caller = array_shift($bt);
     EasyLogger::$logger->log(print_r($caller, true));
 }
Exemplo n.º 2
0
 public static function startLogging()
 {
     self::$start_time = microtime(true);
     self::$memory = memory_get_usage(true);
     $buffer = self::COLOR_SEQ . self::GREEN . "Started at : [" . date('H:i:s d-m-Y', time()) . "]" . self::RESET_SEQ;
     static::getLogger()->log($buffer);
 }
Exemplo n.º 3
0
<?php

/**
 * EasyLogger demo script.
 *
 * Example shows usage of this class in situations when we 
 * want to log some errors (exceptions), which were 
 * generated in our web application.
 */
include_once 'EasyLogger.php';
$logFilePath = dirname(__FILE__) . '/' . 'log.txt';
//Path to the log file. Of course, your log file can be where ever you want.
try {
    throw new Exception('An error occured.');
    //Throw some exception on purpose.
} catch (Exception $ex) {
    try {
        $easyLogger = new EasyLogger($logFilePath, 'Y-m-d');
        //Create EasyLogger instance using custom date format. You can also pass the third parametar to set custom time format.
        $easyLogger->log($ex->getMessage(), EasyLogger::ERR);
        //Log exception message with ERR (error) priority.
    } catch (Exception $ex) {
        echo $ex->getMessage();
    }
}