Skip to content

Instantly share code, notes, and snippets.

@yfix
Last active April 5, 2017 13:19
Show Gist options
  • Save yfix/0bb1da3b49bd66cfbaba7e9047379ae3 to your computer and use it in GitHub Desktop.
Save yfix/0bb1da3b49bd66cfbaba7e9047379ae3 to your computer and use it in GitHub Desktop.
debug_log
<?php
/**
* @example: _debug_log($_POST)
*/
function _debug_log() {
$text = func_get_args();
if (is_array($text) || is_object($text)) {
$text = var_export($text, 1);
}
$dir = rtrim(defined('LOGS_DIR') ? LOGS_DIR : __DIR__, '/').'/';
!file_exists($dir) && mkdir($dir, 0755, true);
$data = [date('Y-m-d H:i:s').' | ', $text];
return file_put_contents($dir.'debug.log', implode($data). PHP_EOL, FILE_APPEND);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment