WP_Logging
in package
Class for logging events and errors
Tags
Table of Contents
- __construct() : void
- Class constructor.
- add() : int
- Create new log entry
- get_connected_logs() : array<string|int, mixed>
- Retrieve all connected logs
- get_log_count() : int
- Retrieves number of log entries connected to particular object ID
- get_logs() : array<string|int, mixed>
- Easily retrieves log items for a particular object ID
- insert_log() : int
- Stores a log entry
- prune_logs() : mixed
- Allows you to tie in a cron job and prune old logs.
- register_post_type() : void
- Registers the wp_log Post Type
- register_taxonomy() : void
- Registers the Type Taxonomy
- update_log() : bool
- Update and existing log item
- get_logs_to_prune() : array<string|int, mixed>
- Returns an array of posts that are prune candidates.
- log_types() : array<string|int, mixed>
- Log types
- prune_old_logs() : mixed
- Deletes the old logs that we don't want
- valid_type() : array<string|int, mixed>
- Check if a log type is valid
Methods
__construct()
Class constructor.
public
__construct() : void
Tags
Return values
void —add()
Create new log entry
public
static add([mixed $title = '' ][, mixed $message = '' ], mixed $parent[, mixed $type = null ]) : int
This is just a simple and fast way to log something. Use self::insert_log() if you need to store custom meta data
Parameters
- $title : mixed = ''
- $message : mixed = ''
- $parent : mixed
- $type : mixed = null
Tags
Return values
int —The ID of the new log entry
get_connected_logs()
Retrieve all connected logs
public
static get_connected_logs([mixed $args = array() ]) : array<string|int, mixed>
Used for retrieving logs related to particular items, such as a specific purchase.
Parameters
- $args : mixed = array()
Tags
Return values
array<string|int, mixed> —/ false
get_log_count()
Retrieves number of log entries connected to particular object ID
public
static get_log_count(mixed $object_id[, mixed $type = null ][, mixed $meta_query = null ]) : int
Parameters
- $object_id : mixed
- $type : mixed = null
- $meta_query : mixed = null
Tags
Return values
int —get_logs()
Easily retrieves log items for a particular object ID
public
static get_logs(mixed $object_id[, mixed $type = null ][, mixed $paged = null ]) : array<string|int, mixed>
Parameters
- $object_id : mixed
- $type : mixed = null
- $paged : mixed = null
Tags
Return values
array<string|int, mixed> —insert_log()
Stores a log entry
public
static insert_log([mixed $log_data = array() ][, mixed $log_meta = array() ]) : int
Parameters
- $log_data : mixed = array()
- $log_meta : mixed = array()
Tags
Return values
int —The ID of the newly created log item
prune_logs()
Allows you to tie in a cron job and prune old logs.
public
prune_logs() : mixed
Tags
Return values
mixed —register_post_type()
Registers the wp_log Post Type
public
register_post_type() : void
Tags
Return values
void —register_taxonomy()
Registers the Type Taxonomy
public
register_taxonomy() : void
The Type taxonomy is used to determine the type of log entry
Tags
Return values
void —update_log()
Update and existing log item
public
static update_log([mixed $log_data = array() ][, mixed $log_meta = array() ]) : bool
Parameters
- $log_data : mixed = array()
- $log_meta : mixed = array()
Tags
Return values
bool —True if successful, false otherwise
get_logs_to_prune()
Returns an array of posts that are prune candidates.
private
get_logs_to_prune() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —$old_logs The array of posts that were returned from get_posts
log_types()
Log types
private
static log_types() : array<string|int, mixed>
Sets up the default log types and allows for new ones to be created
Tags
Return values
array<string|int, mixed> —prune_old_logs()
Deletes the old logs that we don't want
private
prune_old_logs(mixed $logs) : mixed
Parameters
- $logs : mixed
Tags
Return values
mixed —valid_type()
Check if a log type is valid
private
static valid_type(mixed $type) : array<string|int, mixed>
Checks to see if the specified type is in the registered list of types
Parameters
- $type : mixed