Created
July 19, 2012 18:16
-
-
Save pateketrueke/3145775 to your computer and use it in GitHub Desktop.
Logging for PHP with STDERR (Heroku compliant)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('STDERR') OR define('STDERR', fopen('php://stderr', 'w')); | |
logger::implement('write', function ($type, $message) { | |
$remote = server('REMOTE_ADDR'); | |
$message = preg_replace('/[\r\n]+\s*/', ' ', $message); | |
fputs(STDERR, "$remote [$type] $message\n"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment