Today I noticed pieces of code to hook into a logger scattered throughout Gravity Forms, when I was trying to track down an issue. Here’s some quick and dirty code which hooks into the logging methods and writes to the PHP error log:

CAVEAT DEVELOPER: One thing to note, the Gravity Forms logging code does it’s best to skip payment information and suchlike, but I wouldn’t trust it in production as it probably has not been written with that in mind.

/**
 * Fake KLogger class.
 * 
 * @package 
 **/
class KLogger {

    /**
     * Some constants relating to logging, used by GF.
     **/
    CONST EMERGENCY = 'EMERGENCY';
    CONST ALERT = 'ALERT';
    CONST CRITICAL = 'CRITICAL';
    CONST ERROR = 'ERROR';
    CONST WARNING = 'WARNING';
    CONST NOTICE = 'NOTICE';
    CONST INFO = 'INFO';
    CONST DEBUG = 'DEBUG';
}
/**
 * Kinda fake GFLogging class
 * 
 * @package 
 **/
class GFLogging {

    /**
     * A version integer.
     *
     * @var int
     **/
    var $version;

    /**
     * @access @static
     * 
     * @return null
     */
    static public function include_logger() {
        // Not much happens here
    }

    /**
     * Log to PHP error log
     *
     * @return null
     */
    static public function log_message( $slug, $message, $debug_level ) {
        error_log( "GF LOG: $slug, $message, $debug_level" );
    }
}

Photo by Les Haines, from Flickr.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.