How to add custom text in wordpress logs

Hello Please add following code snippet in your theme’s functions.php file

if (!function_exists('write_log')) {
    function write_log ( $log )  {
        if ( true === WP_DEBUG ) {
            if ( is_array( $log ) || is_object( $log ) ) {
                error_log( print_r( $log, true ) );
            } else {
                error_log( $log );
            }
        }
    }
}

Now you can add custom log as and when you wish by using following output

write_log('THIS IS THE START OF MY CUSTOM DEBUG');

write_log($your_variable);

Do let me know if you have any queries.