homologist
Function overriding at compile time
Is there any way to, at compile time overrid ALL functions foo that somebody would wrote in a module A.
I think I can do it overriding def/2. But I feel like i would be using a hammer. Any ideas?
Most Liked
NobbZ
You have to call super explicitly.
But it seems as if you want to use something known as decorators. I’ve seen an experimental package for those years ago, not sure if it still works or is maintained.
At least I remember it had problems with multi headed functions.
The easiest is probably to simply call the logger explicitly at the places you need it…
NobbZ
Or better probably this
def foo(x, y, z) do
log_stuff(...)
do_foo(x, y, z)
end
defp do_foo(...)...
This way only the decorator is accessible and doesn’t have an obfuscated name.
Last Post!
dom
If it’s for logging calls or computing statistics, you could use the standard tracing tools in Erlang’s dbg module.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









