name = $name; $this->wpDebug = defined ( 'WP_DEBUG' ); if (class_exists ( 'PostmanOptions' )) { $this->logLevel = PostmanOptions::getInstance ()->getLogLevel (); } else { $this->logLevel = self::OFF_INT; } } function trace($text) { $this->printLog ( $text, self::TRACE_INT, 'TRACE' ); } function debug($text) { $this->printLog ( $text, self::DEBUG_INT, 'DEBUG' ); } function info($text) { $this->printLog ( $text, self::INFO_INT, 'INFO' ); } function warn($text) { $this->printLog ( $text, self::WARN_INT, 'WARN' ); } function error($text) { $this->printLog ( $text, self::ERROR_INT, 'ERROR' ); } function fatal($text) { $this->printLog ( $text, self::FATAL_INT, 'FATAL' ); } /** * better logging thanks to http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/ * * @param mixed $intLogLevel * @param mixed $logLevelName */ private function printLog($text, $intLogLevel, $logLevelName) { if ($this->wpDebug && $intLogLevel >= $this->logLevel) { if (is_array ( $text ) || is_object ( $text )) { error_log ( $logLevelName . ' ' . $this->name . ': ' . print_r ( $text, true ) ); } else { error_log ( $logLevelName . ' ' . $this->name . ': ' . $text ); } } } public function isDebug() { return self::DEBUG_INT >= $this->logLevel; } public function isTrace() { return self::TRACE_INT >= $this->logLevel; } public function isInfo() { return self::INFO_INT >= $this->logLevel; } } }