Jetpack::log PHP Method

log() public static method

public static log ( $code, $data = null )
    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);
    }

Usage Example

 /**
  * On completion of an automatic update, let's store the results.
  *
  * @param $results - Sent by WP_Automatic_Updater after it completes an autoupdate action. Results may be empty.
  */
 public function automatic_updates_complete($results)
 {
     if (empty($this->expected)) {
         return;
     }
     $this->results = empty($results) ? self::get_possible_failures() : $results;
     add_action('shutdown', array($this, 'bump_stats'));
     Jetpack::init();
     $items_to_log = array('plugin', 'theme');
     foreach ($items_to_log as $items) {
         $this->log_items($items);
     }
     Jetpack::log('autoupdates', $this->get_log());
 }
All Usage Examples Of Jetpack::log
Jetpack