あまりこういうことは書かないのだけれども、あんまりだったので記事にしておく。
FacebookやTwitterのシェア数、フォロー数などをバックグラウンドで取得するWordPressプラグイン
“SNS Count Cache”。
なんか大量にエラーログを吐くので調べてみたら、
WP_DEBUGが立っているとinfoレベルのログをerror_log()で吐く仕様…。
開発環境でエラーログ確認しないのだろうか…。
class SCC_Logger {
/**
* Class constarctor
* Hook onto all of the actions and filters needed by the plugin.
*/
protected function __construct() {
self::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
}
/**
* Output log message according to WP_DEBUG setting
*
* @param string $message Message.
* @return void
*/
public static function log( $message ) {
if ( WP_DEBUG === true ) {
if ( is_array( $message ) || is_object( $message ) ) {
error_log( print_r( $message, true ) );
} else {
error_log( $message );
}
}
}
}
log()というメソッド名でerror_log()を呼ぶというのは想像の斜め上で、
デバッグ初手のアイデアとして浮かばなかった。
/**
* Class constarctor
* Hook onto all of the actions and filters needed by the plugin.
*/
private function __construct() {
SCC_Logger::log( '[' . __METHOD__ . '] (line=' . __LINE__ . ')' );
load_plugin_textdomain( self::DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages' );
add_action( 'init', array( $this, 'initialize' ) );
register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate_plugin' ) );
add_action( 'admin_menu', array( $this, 'register_admin_menu' ) );
add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) );
// add_action( 'admin_notices', array( $this, 'notice_page' ) );
add_action( 'wp_ajax_' . $this->ajax_action, array( $this, 'get_cache_info' ) );
add_action( 'wp_dashboard_setup', array( $this, 'add_wp_dashboard_widget' ) );
add_action( 'deleted_post' , array( $this, 'clear_cache_deleted_post' ) );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_action_links' ), 10, 4 );
}