public static function log($code, $data = null)
{
// only grab the latest 200 entries
$log = array_slice(Jetpack_Options::get_option('log', array()), -199, 199);
// Append our event to the log
$log_entry = array('time' => time(), 'user_id' => get_current_user_id(), 'blog_id' => Jetpack_Options::get_option('id'), 'code' => $code);
// Don't bother storing it unless we've got some.
if (!is_null($data)) {
$log_entry['data'] = $data;
}
$log[] = $log_entry;
// Try add_option first, to make sure it's not autoloaded.
// @todo: Add an add_option method to Jetpack_Options
if (!add_option('jetpack_log', $log, null, 'no')) {
Jetpack_Options::update_option('log', $log);
}
/**
* Fires when Jetpack logs an internal event.
*
* @since 3.0.0
*
* @param array $log_entry {
* Array of details about the log entry.
*
* @param string time Time of the event.
* @param int user_id ID of the user who trigerred the event.
* @param int blog_id Jetpack Blog ID.
* @param string code Unique name for the event.
* @param string data Data about the event.
* }
*/
do_action('jetpack_log_entry', $log_entry);
}