mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
d8cd786079
- application/libraries/* -> CS compliant - FHC_Model isEntitled method now return error() or success() - Updated all code that uses isEntitled method from FHC_Model - Removed Squiz.PHP.DisallowSizeFunctionsInLoops from CS ruleset - Removed depracated method replace from DB_Model - Removed unused method pgArrayPhp from DB_Model - Renamed method arrayMergeIndex to _arrayCombine in DB_Model and set as private - Added method _manageUDFs to DB_Model (a wrapper for UDFLib->manageUDFs)
98 lines
1.8 KiB
PHP
98 lines
1.8 KiB
PHP
<?php
|
|
|
|
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Library usefull for logging!
|
|
*/
|
|
class LogLib
|
|
{
|
|
const DEBUG = 'debug';
|
|
const ERROR = 'error';
|
|
const INFO = 'info';
|
|
|
|
const CALLER_PREFIX = '[';
|
|
const CALLER_POSTFIX = ']';
|
|
const CLASS_POSTFIX = '->';
|
|
const LINE_SEPARATOR = ':';
|
|
|
|
/**
|
|
* format
|
|
*/
|
|
private function format($class, $function, $line)
|
|
{
|
|
$formatted = LogLib::CALLER_PREFIX;
|
|
|
|
if (!is_null($class) && $class != '')
|
|
{
|
|
$formatted .= $class.LogLib::CLASS_POSTFIX;
|
|
}
|
|
|
|
$formatted .= $function.LogLib::LINE_SEPARATOR.$line.LogLib::CALLER_POSTFIX.' ';
|
|
|
|
return $formatted;
|
|
}
|
|
|
|
/**
|
|
* getCaller
|
|
*/
|
|
private function getCaller()
|
|
{
|
|
$classIndex = 3;
|
|
$functionIndex = 3;
|
|
$lineIndex = 2;
|
|
$class = '';
|
|
$function = '';
|
|
$line = '';
|
|
|
|
if (isset(debug_backtrace()[$classIndex]['class']) && debug_backtrace()[$classIndex]['class'] != '')
|
|
{
|
|
$class = debug_backtrace()[$classIndex]['class'];
|
|
}
|
|
|
|
if (isset(debug_backtrace()[$functionIndex]['function']) && debug_backtrace()[$functionIndex]['function'] != '')
|
|
{
|
|
$function = debug_backtrace()[$functionIndex]['function'];
|
|
}
|
|
|
|
if (isset(debug_backtrace()[$lineIndex]['line']) && debug_backtrace()[$lineIndex]['line'] != '')
|
|
{
|
|
$line = debug_backtrace()[$lineIndex]['line'];
|
|
}
|
|
|
|
return $this->format($class, $function, $line);
|
|
}
|
|
|
|
/**
|
|
* log
|
|
*/
|
|
private function log($level, $message)
|
|
{
|
|
log_message($level, $this->getCaller().$message);
|
|
}
|
|
|
|
/**
|
|
* logDebug
|
|
*/
|
|
public function logDebug($message)
|
|
{
|
|
$this->log(LogLib::DEBUG, $message);
|
|
}
|
|
|
|
/**
|
|
* logInfo
|
|
*/
|
|
public function logInfo($message)
|
|
{
|
|
$this->log(LogLib::INFO, $message);
|
|
}
|
|
|
|
/**
|
|
* logError
|
|
*/
|
|
public function logError($message)
|
|
{
|
|
$this->log(LogLib::ERROR, $message);
|
|
}
|
|
}
|