开发者

Why are error_logger messages in different order on the console compared to error_logger_mf file

开发者 https://www.devze.com 2023-03-09 01:58 出处:网络
I\'m looking at error_logger messages on the console and store them in a file with error_logger_mf at the same time.

I'm looking at error_logger messages on the console and store them in a file with error_logger_mf at the same time.

The messages are totally in a different order if I look at the file and the console.

The time-stamps all show the same value, so its going pretty fast, and I do understand that messages could get out of order when sent from different processes.

But I always thought that once the reach the error_logger they are kept in the same order when they are sent to the different event handlers.

What I see that in the files (when I look at it with rb) the events come out in a more sane order than on the console.

Clarification:

It is clear that the order in which messages from different processes arrive at error_logger is not to be take too serious.

What I don't understand is the difference in order, whe开发者_JAVA百科n I compare the disk log to the screen log.


Added a answer as community wiki with my partial findings below, please edit if you know additional points.


Update: this is still unresolved, feel free to add to this community wiki if you know something

Did some digging in the source, but no solution to the riddle so far:

Looked into error_logger_tty_h.erl which should be responsible for output to the console:

handle_event({_Type, GL, _Msg}, State) when node(GL) =/= node() ->
    {ok, State};
handle_event(Event, State) ->
    write_event(tag_event(Event)),
    {ok, State}.

So events that have a group_leader on another node are ignored, everything not ignored is passed through write_event/1. Which does some formatting and then outputs the result with:

format(String)       -> io:format(user, String, []).
format(String, Args) -> io:format(user, String, Args).

In user.erl where io:format sends its io_request we have one server loop calling a cascade of functions that ultimately send the text to the tty port.

At no point there are messages sent from more than one process!

So I can't see any way for the messages to change order while travelling to the tty.

Where else can the order of reports change depending on if the messages are sent to tty or to mf?

0

精彩评论

暂无评论...
验证码 换一张
取 消