|
%% Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved.
|
|
%%
|
|
%% This package, Looking Glass, is double-licensed under the Mozilla
|
|
%% Public License 1.1 ("MPL") and the Apache License version 2
|
|
%% ("ASL"). For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL,
|
|
%% please see LICENSE-APACHE2.
|
|
%%
|
|
%% This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
|
%% either express or implied. See the LICENSE file for specific language governing
|
|
%% rights and limitations of this software.
|
|
%%
|
|
%% If you have any questions regarding licensing, please contact us at
|
|
%% info@rabbitmq.com.
|
|
|
|
-module(lg_raw_console_tracer).
|
|
|
|
-export([start_link/2]).
|
|
-export([init/1]).
|
|
-export([loop/1]).
|
|
|
|
-export([system_continue/3]).
|
|
-export([system_terminate/4]).
|
|
-export([system_code_change/4]).
|
|
|
|
start_link(_Nth, _Opts) ->
|
|
Pid = proc_lib:spawn_link(?MODULE, init, [self()]),
|
|
{ok, Pid}.
|
|
|
|
init(Parent) ->
|
|
%% Store all messages off the heap to avoid unnecessary GC.
|
|
process_flag(message_queue_data, off_heap),
|
|
loop(Parent).
|
|
|
|
loop(Parent) ->
|
|
receive
|
|
{system, From, Request} ->
|
|
sys:handle_system_msg(Request, From, Parent, ?MODULE, [], Parent);
|
|
Msg0 ->
|
|
%% Convert the event's monotonic time to its system time.
|
|
Msg = setelement(3, Msg0, erlang:time_offset(microsecond) + element(3, Msg0)),
|
|
erlang:display(Msg),
|
|
loop(Parent)
|
|
end.
|
|
|
|
system_continue(_, _, Parent) ->
|
|
loop(Parent).
|
|
|
|
-spec system_terminate(any(), _, _, _) -> no_return().
|
|
system_terminate(Reason, _, _, _) ->
|
|
exit(Reason).
|
|
|
|
system_code_change(Misc, _, _, _) ->
|
|
{ok, Misc}.
|