Skip to main content

Custom Logging Functions

These functions write logs to the yoko-logs folder in the current site's uploads folder.

yoko_log( $message, $filename ) function

A custom logging function. Writes to a file with today's date prepended.

Syntax

To write a message to the [YYYY-MM-DD]-yoko-error.log log file, use this function:

yoko_log(
'This is my message to you hoo hoo',
'error'
);

`yoko_log_nodate( $message, $filename )

Use this function to write to a file with no date prepended.

Syntax

To write a message to the yoko-error.log log file, use this function:

yoko_log_nodate(
'This is my message to you hoo hoo',
'error'
);

yoko_post_log( $message, $post_id ) function

A custom logging function that writes to a post specific log file in the folder [POST TYPE]-logs. If this log file exists, a meta box with the output of this file is rendered on the post edit screen.

Syntax

To write a log messate for an event post with id 97531, use this function:

yoko_post_log(
'This is my message to you hoo hoo',
97531
);

This log will render in the Post Log metabox of this event post:

Post Log Metabox