Skip to content

Instantly share code, notes, and snippets.

@blackode
Last active August 6, 2022 17:16
Show Gist options
  • Save blackode/b7cecbbfcdeff3921f0dc7176a2f6820 to your computer and use it in GitHub Desktop.
Save blackode/b7cecbbfcdeff3921f0dc7176a2f6820 to your computer and use it in GitHub Desktop.
Debugger Information
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