Created
November 1, 2014 09:01
-
-
Save kawahara/f5de6c39e69c4b86b3fd to your computer and use it in GitHub Desktop.
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
<?php | |
$fp = fopen(__DIR__.'/logs/access.log', 'a'); | |
$headers = []; | |
foreach($_SERVER as $name => $value) { | |
if (preg_match('/^HTTP_.*/', $name)) { | |
$headers[$name] = $value; | |
} | |
} | |
$logData = [ | |
date('Y-m-d H:i:s'), | |
$_SERVER['HTTP_HOST'], | |
$_SERVER['REQUEST_URI'], | |
json_encode($_POST, JSON_UNESCAPED_UNICODE), | |
json_encode($headers, JSON_UNESCAPED_UNICODE) | |
]; | |
fwrite($fp, implode("\t", $logData)."\n"); | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment