Skip to content

Instantly share code, notes, and snippets.

@windix
Last active January 3, 2016 04:39
Show Gist options
  • Save windix/8410876 to your computer and use it in GitHub Desktop.
Save windix/8410876 to your computer and use it in GitHub Desktop.
<?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/');
});
}
}
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