Last active
August 6, 2022 17:16
-
-
Save blackode/b7cecbbfcdeff3921f0dc7176a2f6820 to your computer and use it in GitHub Desktop.
Debugger Information
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
defmodule Salt.Debugger do | |
@moduledoc false | |
def debugger(code, _options, caller, device) do | |
quote do | |
# calculating the result | |
result = unquote(code) | |
module = unquote(caller.module) | |
{fun_name, arity} = unquote(caller.function) | |
line_number = unquote(caller.line) | |
file = unquote(caller.file) | |
io = unquote(device) | |
# Colors to Add | |
cyan = IO.ANSI.cyan() | |
magenta = IO.ANSI.magenta() | |
yellow = IO.ANSI.yellow() | |
reset = IO.ANSI.reset() | |
white = IO.ANSI.white() | |
header = [ | |
white, | |
IO.ANSI.blink_slow(), | |
"=====*** [Salt Debugger] ***=====", | |
reset | |
] | |
header = Enum.join(header) | |
module = cyan <> "Moduel Name : #{module}" <> reset | |
fun = magenta <> "Function Name: #{fun_name}/#{arity}" <> reset | |
file = yellow <> "File : #{file} line: (#{line_number})" <> reset | |
IO.puts("\n") | |
IO.puts(io, header) | |
IO.puts("\n") | |
IO.puts(io, module) | |
IO.puts(io, fun) | |
IO.puts(io, file) | |
IO.puts("\n") | |
IO.puts(io, header) | |
IO.puts("\n") | |
IO.inspect(io, result, label: unquote(Macro.to_string(code))) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment