LogStore can be used to log (important) data from within your plugin.
It provides a simple interface to log entries and a friendly administration interface for viewing and managing the log entries.
While LogStore can be used to log debug output or system events, it’s main intention is to log more extensive data, such as:
To use LogStore in your plugin, add the following line to your plugin’s ‘plugins_loaded’ callback function:
if (class_exists('LogStore')) $this->log = new LogStore('slug', __('Title'));
Once that’s done you can then start logging your data from anywhere within your plugin by using the following:
if (!empty($this->log)) $this->log->log(__('My log message'), $my_log_data, 'status', 'tag');
If you use LogStore in your plugin, you should check for it’s presence in
You should either make LogStore use optional or notify the user that they need to install LogStore for your plugin to work properly.
In the following hooks, *myname*
stands for the name with which you instanciated the LogStore class.
logstore_init-*myname*
– runs during the execution of WP’s init
action hook, passes a single boolean parameter indicating if logging is active or inactive for this loggerlogstore_new_entry-*myname*
– runs during the creation of a new entry, passes a single array containing all values for that entry (‘time’, ‘message’, ‘data’, ‘status’ and ‘tag’)logstore_entry-*myname*
– runs before displaying an entry on screen, passes a single array containting all values for the entry (‘time’, ‘message’, ‘data’, ‘status’ and ‘tag’)logstore_format_entry_data-*myname*
– runs before displaying the formatted data on screen, passes the formatted data as stringPlease note that the ‘bulk actions’ in the log viewer are currently not
working.