Last active
January 3, 2016 04:39
-
-
Save windix/8410876 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 | |
// debug log full | |
function _dbg_logf() { | |
$args = func_get_args(); | |
_dbg_log_core(true, $args); | |
} | |
// debug log standard | |
function _dbg_log() { | |
$args = func_get_args(); | |
_dbg_log_core(false, $args); | |
} | |
function _dbg_log_core($with_trace, $args) { | |
$msg = ""; | |
//trace | |
if ($with_trace) { | |
$stack = debug_backtrace(); | |
foreach ($stack as $item) { | |
$type = var_set($item['type']); | |
$msg .= '<<<<----' . var_set($item['file'], '-') . ':' . var_set($item['line'], '0') . ' ' . var_set($item['class'], ' ') . $type . var_set($item['function']) . "\n"; | |
} | |
} | |
foreach ($args as $arg) { | |
if (is_string($arg) || is_numeric($arg)) { | |
$msg .= $arg; | |
} else { | |
$msg .= Logger::var_export($arg); | |
} | |
$msg .= "\n"; | |
} | |
Logger::log_to_file($msg, "debug"); | |
if (class_exists('ChromePhp')) { | |
ChromePhp::log($msg); | |
} | |
} | |
function _dbg_get_included_files($filter = "") { | |
if (empty($filter)) { | |
return get_included_files(); | |
} else { | |
return array_filter(get_included_files(), function($item) use ($filter) { | |
return strpos($item, 'wagerplayer/betshop/'); | |
}); | |
} | |
} |
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
Save this one to shared/confg/debug.php | |
and require it from client_config.php | |
usage: | |
_dbg_log(...) for simple log | |
_dbg_logf(...) for log with full stack trace | |
the result goes to debug.log in your log folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment