Description
Filter that allows capture of various plugin messages that can be used for debugging. Useful for keeping an activity log of the actions performed by the plugin.
Parameters
- $message
-
(string)(required) The message returned by the plugin.
- Default:None
- $separator
-
(string)(optional) Message separator.
- Default:\n (new line)
- $data
-
(array)(optional) An array of data returned by the plugin with the message.
- Default:false
Examples
A simple example of catching the message and writing it into a file (please note that the code below won’t rotate the log file).
function my_function( $message, $separator, $data ){ $upload_dir = wp_upload_dir(); $log_file = $upload_dir['basedir'] . '/vimeo_log'; $handle = fopen( $log_file, "a" ); $log_entry = sprintf( __( '[%s] %s', 'cvm_video' ), date( 'M/d/Y H:i:s' ), $message ); fwrite( $handle, $log_entry ."\n" ); fclose( $handle ); } add_filter( 'cvm_debug_message', 'my_function', 10, 3 );