Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated logging towards GRiSP.io #18

Merged
merged 22 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,39 @@ Accepts an integer that represents the maximum number of logs that can be batche
ok = grisp_io:connect().
true = grisp_io:is_connected().
{ok, <<pong>>} = grisp_io:ping().

## See all logs from boot on GRiSP.io

Once this app is started, it forwards all logs to GRiSP.io without the need of setting up anything. The only logs that we do not catch are the ones generated before `grisp_io` boots.
If you want to see ALL logs, even from applications that boot before `grisp_io`, you need to disable the default logger and set our logger as the default one. This involves changing the `kernel` and `grisp_io` app configuration settings in your sys.config file.

You can copy paste these settings. Here we both swap the default logger with ours and also request our logger to print logs to stdout.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording is a bit strange. It's not our logger, but a handler for the OTP logger. I would rather talk about "the grisp_io logger handler" (or when we rename the repo "the grisp_connect logger handler"). Same for default logger, it's the default logger handler.

```erlang
% sys.config
[
{kernel, [
{logger_level, debug},
% Disable 'default' handler (which buffers all log events in logger).
{logger, [{handler, default, undefined}]}
]},
{grisp_io,[
{logger, [
% Enable our own default handler,
% which will receive all events from boot
{handler,
default,
grisp_io_logger_bin,
#{
formatter => {grisp_io_logger_bin, #{
% If you want to see logs printed on the USB serial,
% here you can appoint a logger formatter module of your choice
% and set your preferred configuration for OTP logs
% setting: stdout => {Formatter, FormatterConfig}
stdout => {logger_formatter, #{}}
}}
}
}
]}
]}
].
```
1 change: 0 additions & 1 deletion src/grisp_io_logger_bin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ format(Event, Config) ->
case EncodedSize > ?MAX_LOG_BYTES of
true ->
NewLog = log_discard(EncodedSize),
io:format("Replacing big log with ~p~n",[NewLog]),
base64:encode(term_to_binary(NewLog));
false ->
Encoded
Expand Down
Loading