Keeping dependencies quiet in Erlang

I am using chumak in an Erlang-based ZMQ server. I am listening and spawning processes to accept connections:

          {ok, LSocket} = chumak:socket(rep),                                                                                                                                
          {ok, _} =  chumak:bind(LSocket, tcp, "0.0.0.0", ?PORT),                                                                                                    
          spawn_link(fun() -> loop(LSocket, DBConn, RedisConn) end),

That all works fine. But there is one problem. When something "unexpected" (from chumak's point of view) happens, such as a port scan connecting to its port, the process to accept data may die. That's fine, because it restarts automatically. What's not fine is that when this happens, chumak sprays its errors all over the console. I don't care about them.

Is there any way to shut up a dependency library, in Erlang?

Upvotes: 0

Views: 67

Answers (1)

Brujo Benavides
Brujo Benavides

Reputation: 1958

chumak errors are emitted through error_logger. That means, to prevent them from being displayed you have to tell your error_logger handler not to display them.

I'll guess you're using sasl for that. If that's the case, what you need to do is to add this configuration to sasl environment: {sasl_error_logger, false}.

But be careful, you'll be disabling all error logs from displaying if you do so. I'm not sure if you can tell sasl to skip particular kinds of error reports instead. If that's possible, you will want not to print out error messages for bind_error reports.

Upvotes: 1

Related Questions