a6smile / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Enable some logging to error_log #217

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Checking error_log is easier for some than setting up FirePHP. There could be 
an option to log all exceptions and some empty controller sets to error_log.

Out of the box we should check for $_GET['f'] == 
'path/to/min/builder/_index.js' and turn on error_log for this URL. Problems 
serving this usually point to some bigger problem w/ the PHP environment.

Original issue reported on code.google.com by mrclay....@gmail.com on 20 Jan 2011 at 8:07

GoogleCodeExporter commented 9 years ago
This could work fine with PEAR Log class, if the extra $ident wasn't there.

    require_once 'Log.php';
    require_once 'Minify/Logger.php';
    $log = Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'minify');
    Minify_Logger::setLogger($log);

it basically works, but throws warning to errorlog:

2012-03-29 22:26:41: (mod_fastcgi.c.2699) FastCGI-stderr: PHP Notice:  
Undefined index:  Minify in /usr/share/pear/Log.php on line 591
minify: A group configuration for "f" was not found

i.e the $label Minify would be expected by pear logger as priority:

    public static function log($msg, $label = 'Minify') {
        if (! self::$_logger) return;
        self::$_logger->log($msg, $label);
    }

Original comment by elan.ruu...@gmail.com on 29 Mar 2012 at 7:31

GoogleCodeExporter commented 9 years ago
such simple class could do it with Pear logger:

/**
 * @author Elan Ruusamäe <glen@delfi.ee>
 */
class Logger {
    private $logger;

    public function __construct($ident) {
        $this->logger = Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, $ident);
    }

    /**
     * Pass a message to the logger (if set)
     *
     * @param string $msg message to log
     * @return null
     */
    public function log($msg, $label = 'Minify') {
        $this->logger->log($msg);
    }
}

    $log = new Logger('Minify');
    Minify_Logger::setLogger($log);

Original comment by elan.ruu...@gmail.com on 29 Mar 2012 at 7:40

GoogleCodeExporter commented 9 years ago
The plan is to replace Minify_Logger with an interface, and pass the logger 
directly into Minify::serve() and have it pass it on to the cache, etc. The aim 
is to remove all the statics eventually.

Original comment by mrclay....@gmail.com on 29 Mar 2012 at 8:12