I’d like to extend IO.inspect to also emit the file and line number of the statement.
IO.inspect
I had this in Ruby and found it to be super helpful.
Would there be any way in Elixir to write a function or macro that could introspect, maybe at compile time, to capture the file and line number?
In general this is accessible from the __ENV__ struct, there are fields for various things like file, line, current function, module, etc. Inside macros the __CALLER__ macro returns similar information for the place where the macro was called.
__ENV__
__CALLER__
Many thanks for this tip!