Skip to Content


Add an entry to the Nebula administrative log.

PHP May 1, 2020


nebula()->add_log($message, $importance)


(Required) (String) The message text
Default: None

(Optional) (Integer) How important this log is (0-10)
Default: None

Parameter Notes

Do not include personally identifiable information in the message. This log database is meant for strictly administrative events– this is not meant to log visitor usage data or personal information!

Logs with an importance of 0 may be automatically removed to save space in the log database.

Note: A timestamp is automatically added to the message as well as the user who logged the message (so those are not needed in the message string).

Request or provide clarification »

Additional Notes

This log option is disabled by default! It will not log anything when disabled, so retroactive logs are not possible. It is available in Nebula Options in the Administrative tab and logs themselves can be viewed in Nebula Options in the Diagnostics tab.

Some examples of administrative events that are logged by Nebula itself:

  • Nebula theme activation
  • Nebula theme updates (via WordPress updater)
  • WordPress core updates (via WordPress updater)
  • Nebula Options saved
  • Admin user registration
  • Automatic Sass disabling

Source File

Located in /libs/Utilities/Logs.php on line 86.

No Hooks

This function does not have any filters or actions available. Request one?

Note: This function contains 1 to-do comment.

        public function add_log($message='', $importance=0, $optimize=true){
            if ( $this->get_option('logs') && is_user_logged_in() && !empty($message) ){
                global $wpdb;

                $log_insertion = $wpdb->insert($wpdb->nebula_logs, array(
                    'timestamp' => sanitize_text_field(date('U')),
                    'message' => sanitize_text_field($message),
                    'user_id' => intval(get_current_user_id()), //Note: returns 0 in cron jobs
                    'importance' => intval($importance)
                )); //DB Query


                if ( !empty($optimize) ){
                    //$this->optimize_logs(); //@todo "nebula" 0: Need to test this before enabling!

                if ( $this->is_debug(false) || WP_DEBUG || WP_DEBUG_LOG ){
                    $this->debug_log($message . ' [User: ' . get_userdata(intval(get_current_user_id()))->display_name . ']'); //Log the message to a file too when debug mode is active

                return is_int($log_insertion); //Boolean return

            return false;


This function can not be short-circuited with an override filter. Request one?