Associating Audit Entries With a Module

Typically your audit messages will be associated with a particular module. You can set which module your audit entry relates to by passing the module as either the second argument to the Application_Auditor_Message constructor, or by calling the setModule() method.

You can pass either the name of a module, or an instance of Application_Module_Interface.

Setting the module on your audit messages allows administrators to better understand your audit messages, and also allows them to easily filter messages. This can also help you in development of your module.

The following shows an example of setting the module on your audit message.

Example 4.2. Setting the module for an audit message

<?php
    // set module in constructor
    $message = new Application_Auditor_Message('Some action occurred', 'mymodule');
    $message->record();
    
    // set module with setModule() method
    $message = new Application_Auditor_Message('Some action occurred');
    $message->setModule('mymodule')
            ->record();
            
    // pass an instance of Application_Module
    $module = Application_Module_Manager::Factory('mymodule');
    $message = new Application_Auditor_Message('Some action occurred', $module);
    $message->record();
?>