Custom backend for elixir compilation warnings

59 views
Skip to first unread message

Boris Kuznetsov

unread,
Feb 23, 2021, 1:12:24 AM2/23/21
to elixir-lang-core
Hi,

I’m working on console application written in elixir.
I would like to make it “live editable”, so I run it with mix run --no-halt.

It has shortcut to trigger recompilation with IEx.Helpers.recompile().

The issue I have is that many parts of elixir write to stdout when you trigger recompilation.

So far, it has two type of messages:
1) success / failure messages, handled by Mix.shell.info/1Mix.shell.error/1
2) compilation warning messages, handled by :elixir_errors module.

Mix.shell allows you to define custom behaviour for its actions with Mix.shell(Custom.MixShell).

To do the same thing with :elixir_errors Erlang’s module, you have to re-define it from scratch.

Is it possible to have custom backend for :elixir_errors module?

The issue I’m trying to resolve is my application has many virtual windows and I want to show all warnings / errors in separate windows, i.e. redirect output from stdout to some file as an example.

Thank you.

José Valim

unread,
Feb 23, 2021, 2:59:46 AM2/23/21
to elixir-l...@googlegroups.com
Hi Boris!

The compile mix tasks already returns all diagnostics as a data structure, so I would recommend you to implement your own IEx.Helper.recompile so you have access to those diagnostic values. It should be relatively straight-forward.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/BFA65702-1BBF-4D75-98AD-99FB782CEF6E%40achempion.com.

Boris Kuznetsov

unread,
Feb 23, 2021, 3:13:18 AM2/23/21
to elixir-lang-core
Probably I could get the resulting data structure, but the real challenge I think is to suppress all the stdout messages issued by many different mix tasks used in recompilation process.

Here is the example:
When we trigger recompilation, we still get this warning to the main window’s stdout.

The only way I can see how to remove it from stdout is to override the :elixir_errors.erl_warn/3 function.

Reply all
Reply to author
Forward
0 new messages