Forked from yanknudtskov/wordpress-debugging-classes.php
Created
June 18, 2018 06:57
-
-
Save INDIAN2020/43856ed329d1f03d217fe9afb7b90639 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class My_Class { | |
| public function my_func() { | |
| // We can error log our data here. | |
| error_log( __LINE__ ); // outputs 6 | |
| // Or we can also log which method we're in | |
| error_log( __METHOD__ ); // outputs My_Class::my_func | |
| } | |
| } | |
| function my_function() { | |
| // With functions, you can also log their function name | |
| error_log( __FUNCTION__ ); // outputs my_function | |
| } | |
| function log_this(){ | |
| // You can also combine them, here is a basic example | |
| error_log( sprintf( '%s - %s::%d', date( 'F j Y', time() ), __FUNCTION__, __LINE__ ) ); | |
| // Will output something like August 1, 2015 - log_this::21 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment