Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * debug_log
- * @param {*} $data
- * @param {string} $d = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough"
- * */
- function debug_log($data, $type = ''){
- $patterns = [
- "black" => "[30mstr[39m",
- "red" => "[31mstr[39m",
- "green" => "[32mstr[39m",
- "yellow" => "[33mstr[39m",
- "blue" => "[34mstr[39m",
- "magenta" => "[35mstr[39m",
- "cyan" => "[36mstr[39m",
- "white" => "[37mstr[39m",
- "gray" => "[90mstr[39m",
- "bold" => "[1mstr[22m",
- "dim" => "[2mstr[22m",
- "italic" => "[3mstr[23m",
- "underline" => "[4mstr[24m",
- "inverse" => "[7mstr[27m",
- "hidden" => "[8mstr[28m",
- "strikethrough" => "[9mstr[29m",
- ];
- if (!is_string($data) && !is_numeric($data)) {
- $data = json_encode($data, JSON_PRETTY_PRINT);
- }
- if ($type && isset($patterns[$type])) {
- $pattern = $patterns[$type];
- $data = str_replace('str', $data, $pattern);
- }
- file_put_contents('php://stderr', $data);
- file_put_contents('php://stderr', "\n");
- }
Add Comment
Please, Sign In to add comment