function debug_dump_yaml($opts, $pipe = null, $offset = 0) { if (debug_mode()) { return dump_yaml($opts, $pipe, $offset); } return get_opts_or_pipe($opts, $pipe); }
function message($cmd, $msg, $type, $debug = false) { # adjust output for if is a normal command if (is_null($msg) || is_array($msg)) { # set the message if (is_string($cmd)) { $msg = $cmd; } elseif (is_array($cmd)) { $msg = get_opt($cmd, 'msg'); if (!check_opt_set_type($cmd, $msg, 'msg', 'string')) { return false; } } # set the command if ($debug) { $cmd = "debug_{$type}"; } else { $cmd = $type; } } else { # split the substring from the command $cmd = explode(':', $cmd); $cmd = $cmd[0]; } # switch on type switch ($type) { case 'error': case 'warning': case 'notice': case 'echo': break; case 'none': return true; default: $msg = "unknown message type '{$type}'"; $type = 'error'; dump_yaml(debug_backtrace); } # build output array $out = array(); if ($cmd && $cmd != $type && $cmd != "debug_{$type}") { $out[] = "[{$cmd}] "; } if ($type != 'echo') { $out[] = '[' . strtoupper($type) . '] '; } $out[] = ucfirst($msg); $out = implode($out); # echo message echo "{$out}\n"; # return false on error if ($type == 'error') { $GLOBALS['error_msg'] = trim($out); return false; } }