Skip to content

Instantly share code, notes, and snippets.

@lf-uraku-yuki
Last active December 14, 2017 16:06
Show Gist options
  • Save lf-uraku-yuki/f18667242e6676de8fed289f1375305c to your computer and use it in GitHub Desktop.
Save lf-uraku-yuki/f18667242e6676de8fed289f1375305c to your computer and use it in GitHub Desktop.
CodeIgniter 3.x Logging Back Trace Helper
<?php
if (! function_exist('logDebug')) {
function logDebug($message)
{
$trace = debug_backtrace();
$output = 'UserLog: ' . $trace[1]["class"] . '::' . $trace[1]['function'] . ' - ';
if (is_array($message)) {
$message = print_r($message, true);
}
$output .= $message;
log_message('debug', $output);
}
}
if (! function_exists('logError')) {
function logError($message)
{
$trace = debug_backtrace();
$output = 'UserLog: ' . $trace[1]["class"] . '::' . $trace[1]['function'] . ' - ';
if (is_array($message)) {
$message = print_r($message, true);
}
$output .= $message;
log_message('error', $output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment