Log

Contents...

The framework utilizes a common user actions logging mechanism. For example, the system log can be used for statistical analysis of user actions.

Information about user actions is saved in table wa_log, which is common for applications. Below are listed the table fields and the types of values they contain:

  • app_id: application APP_ID
  • contact_id: the ID of the user whose action is logged
  • datetime: user action date and time
  • action: string-type identifier (type/name) of the user action
  • count: number of objects affected by action (is applied to multiple actions; e.g., when several records are deleted or updated in one action)

How to enable logging:

  1. Declare the actions which must be logged in your applications. To do so, create configuration file wa-apps/{APP_ID}/lib/config/logs.php and specify the identifiers of the desired actions in it; e.g.:

    <?php
    
    return array(
        'contact_add' => array(),
        'contact_edit' => array(),
        'contact_delete' => array(),
        'contact_merge' => array(),
        'form_signup' => array()
    );
    
  2. Call the logging method in the PHP code of controllers and actions as shown below:

    $this->log($action_name, $count);

Example:

<?php

class StickiesStickyActions extends stickiesJsonActionsController
{

    ...
    protected function addAction()
    {
        ...
        $this->log('sticky_add', 1);
        ...
    }
    ...

}