Created
March 23, 2012 06:01
-
-
Save DevelopKim/2167475 to your computer and use it in GitHub Desktop.
PHP debug logging file and browser
This file contains 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
<? | |
//logging file | |
function debug_log($message = '<==========DEBUG LOG========>'){ | |
//directory log file | |
$dir = $_SERVER['DOCUMENT_ROOT'].'/logs'; | |
//save Output Buffer | |
ob_start(); | |
print_r($message); | |
$message = ob_get_clean(); | |
if(!file_exists($dir)){ | |
mkdir($dir); | |
} | |
//set time | |
date_default_timezone_set('Asia/Seoul'); | |
$logData = '['.date('Y/m/d G:i:s').'] '.$message; | |
error_log($logData.PHP_EOL,3,$dir.'/'.date('Ymd').'.log'); | |
} | |
//logging browser | |
function debug_log_view($message = '<==========DEBUG LOG========>'){ | |
echo('<div style="border:1px solid;"><pre>'); | |
ob_start(); | |
print_r($message); | |
ob_end_flush(); | |
echo('</pre></div>'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment