pclib  3.0.0
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...
 
 getSize ()
 Return size of the log in MB. 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...
 
 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.
 
 $categories = array('ALL')
 Only messages with following categories will be logged. More...
 
 $storage
 var LoggerDbStorage
 
 $auth
 var Auth
 
- Data Fields inherited from BaseObject
 $serviceLocator
 var function() Return service object when requested with service().
 

Protected Member Functions

 getStorage ()
 Return storage object - if not exists, create one.
 
- Protected Member Functions inherited from BaseObject
 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()

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

Member Function Documentation

◆ deleteLog()

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()

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

◆ getSize()

getSize ( )

Return size of the log in MB.

Returns
int $size

◆ log()

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

$categories = array('ALL')

Only messages with following categories will be logged.

By default, all categories are logged.


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