pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Logger Class Reference

This class offers fast and space-saving database logger. More...

Inheritance diagram for Logger:
BaseObject

Public Member Functions

 __construct ($name=null)
 
 log ($category, $message_id, $message=null, $item_id=null)
 Store message to the log, if it has allowed category. More...
 
 getLog ($rowCount, array $filter=null)
 Return last $rowcount records from the log. More...
 
 deleteLog ($keepDays, $allLogs=false)
 Remove old records in log. More...
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 addEvent ($name, $callback)
 Add event handler to $object->$name property. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $name = 'LOGGER'
 Name of the logger.
 
 $disabled = false
 If you set disabled to true, nothing will be written into log. More...
 
 $categories = array('ALL')
 Only messages with following categories will be logged. More...
 
 $storage
 var LoggerDbStorage
 
 $auth
 var Auth
 
- Data Fields inherited from BaseObject
 $onNewInstance
 Occurs when new instance of the class is created. More...
 
 $onMissingMethod
 Occurs when called method does not exist. More...
 
 $serviceLocator
 var function() Return service object when requested with service(). More...
 

Protected Member Functions

 getStorage ()
 Return storage object - if not exists, create one. More...
 
- Protected Member Functions inherited from BaseObject
 fireEvent ($name, array $args=array())
 Run all event handlers in $object->$name property. More...
 
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Protected Attributes

 $app
 var App
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 

Detailed Description

This class offers fast and space-saving database logger.

You can store any program events (actions) alltogether with user_id, item_id, browser, ip-address or even with additional message. Only numerical ID are stored into LOG so it is very compact. The lookup table which contains text labels bounded with IDs is updated automatically.

Constructor & Destructor Documentation

__construct (   $name = null)
Parameters
$nameLogger name (Same as application name by default)

Member Function Documentation

deleteLog (   $keepDays,
  $allLogs = false 
)

Remove old records in log.

It will keep $keepdays in the log.

Parameters
int$keepDaysNumber of days to keep in the log
bool$allLogsThis logger only / all loggers
getLog (   $rowCount,
array  $filter = null 
)

Return last $rowcount records from the log.

Parameters
int$rowCountNumber of rows
array$filterSet filter on USER,ACTION,LOGGER. Ex: array('USER'=>'joe')
Returns
array Array of records
getStorage ( )
protected

Return storage object - if not exists, create one.

log (   $category,
  $message_id,
  $message = null,
  $item_id = null 
)

Store message to the log, if it has allowed category.

Only categories in logger->categories will be logged. You can use your own categories too.

Parameters
string$categoryMessage category such as AUTH_WARNING or PHP_ERROR.
string$message_idFor logging repeated events such as 'user/delete'
string$messageFill it if you need log full text message
int$item_idAdditional id of related object
Returns
$id

Field Documentation

$categories = array('ALL')

Only messages with following categories will be logged.

By default, all categories are logged.

$disabled = false

If you set disabled to true, nothing will be written into log.


The documentation for this class was generated from the following file: