I currently use the server side events to log changes, as described here:
function logChange ( $db, $action, $id, $values ) {
$db->insert( 'staff-log', array(
'user' => $_SESSION['username'],
'action' => $action,
'values' => json_encode( $values ),
'row' => $id,
'when' => date('c')
) );
}
Editor::inst( $db, 'staff' )
->fields(
Field::inst( 'first_name' ),
Field::inst( 'last_name' ),
Field::inst( 'position' ),
Field::inst( 'email' ),
Field::inst( 'office' )
)
->on( 'postCreate', function ( $editor, $id, $values, $row ) {
logChange( $editor->db(), 'create', $id, $values );
} )
->on( 'postEdit', function ( $editor, $id, $values, $row ) {
logChange( $editor->db(), 'edit', $id, $values );
} )
->on( 'postRemove', function ( $editor, $id, $values ) {
logChange( $editor->db(), 'delete', $id, $values );
} )
->process( $_POST )
->json();
However, it would be really useful to also log errors associated with datatables events. For example, the information which appears if you have ->debug( true )
enabled or JSON response errors.
Has anyone else tried/achieved this? I am just at the thinking it through stage so was wondering if anyone had any experience?
Thanks