Skip to content

Instantly share code, notes, and snippets.

@yanknudtskov
Created October 18, 2015 20:06
Show Gist options
  • Save yanknudtskov/780da066ad11c701ce2a to your computer and use it in GitHub Desktop.
Save yanknudtskov/780da066ad11c701ce2a to your computer and use it in GitHub Desktop.
<?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