\PhalApi_Logger

Logger Class

  • Record various cases of the project, storage depends upon the implementation of sub-class
  • There is no priority for logger level, and they can combine with each other


Implementation and usage:

     class PhalApi_Logger_Mock extends PhalApi_Logger {
         public function log($type, $msg, $data) {
             // nothing to do here ...
         }
     }

     // save all kinds of the logs
     $logger = new PhalApi_Logger_Mock(
         PhalApi_Logger::LOG_LEVEL_DEBUG | PhalApi_Logger::LOG_LEVEL_INFO | PhalApi_Logger::LOG_LEVEL_ERROR);

     // this is for developers, with more detail
     $logger->debug('this is bebug test', array('name' => 'mock', 'ver' => '1.0.0'));

     // this is for business
     $logger->info('this is info test', 'and more detail here ...');

     // something should not happen
     $logger->error('this is error test');

Summary

Methods
Properties
Constants
__construct()
log()
info()
debug()
error()
No public properties found
LOG_LEVEL_DEBUG
LOG_LEVEL_INFO
LOG_LEVEL_ERROR
isAllowToLog()
$logLevel
N/A
No private methods found
No private properties found
N/A

Constants

LOG_LEVEL_DEBUG

LOG_LEVEL_DEBUG

LOG_LEVEL_INFO

LOG_LEVEL_INFO

LOG_LEVEL_ERROR

LOG_LEVEL_ERROR

Properties

$logLevel

$logLevel : integer

Type

integer — log level, can be multi

Methods

__construct()

__construct(  $level) 

Parameters

$level

log()

log(string  $type, string  $msg, \string/array  $data) : NULL

Record log

wtite the log into different storage medium according your need

Parameters

string $type

the type of log, such as info, debug, error, etc.

string $msg

key description of log

\string/array $data

infomation of the context

Returns

NULL

info()

info(string  $msg, \string/array  $data = NULL) : NULL

The logs in production level

Parameters

string $msg

key description of log

\string/array $data

infomation of the context

Returns

NULL

debug()

debug(string  $msg, \string/array  $data = NULL) : NULL

The logs in debugger level

Parameters

string $msg

key description of log

\string/array $data

infomation of the context

Returns

NULL

error()

error(string  $msg, \string/array  $data = NULL) : NULL

The logs in system error level

Parameters

string $msg

key description of log

\string/array $data

infomation of the context

Returns

NULL

isAllowToLog()

isAllowToLog(integer  $logLevel) : boolean

Is allowed to write into or not, arithmetic or operation

Parameters

integer $logLevel

Returns

boolean