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

Log additional information on crashes from rexi #746

Merged
merged 1 commit into from Aug 16, 2017

Conversation

Projects
None yet
2 participants
@iilyak
Contributor

iilyak commented Aug 10, 2017

Overview

This improve the log messages from rexi. It adds flowing info:

  • nonce
  • node originator of the request
  • mfa of the function called
  • client Pid

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;
@chewbranca

This comment has been minimized.

Show comment
Hide comment
@chewbranca

chewbranca Aug 11, 2017

Contributor

Overall I think this looks good, but I'm a bit confused as to why the nonce isn't getting logged already. We write the log entry in [1], which includes the MsgId in [2], and we set that value in [3] by way of [4]. This log statement is happening in rexi_server:init_p/3 which is already recording the nonce [5], so I'm a bit confused as to why the nonce is not showing up as expected, or even the fall back msg_id [6].

[1]

write(Entry, St) ->
#log_entry{
level = Level,
pid = Pid,
msg = Msg,
msg_id = MsgId,
time_stamp = TimeStamp
} = Entry,
Fmt = "<~B>~B ~s ~s ~s ~p ~s - ",
Args = [
St#st.facility bor get_level(Level),
?SYSLOG_VERSION,
TimeStamp,
St#st.hostname,
St#st.appid,
Pid,
MsgId
],
Pre = io_lib:format(Fmt, Args),
ok = send(St, [Pre, Msg, $\n]),
{ok, St}.

[2]
[3]
msg_id = couch_log_util:get_msg_id(),

[4]
case erlang:get(nonce) of

[5]
put(nonce, Nonce),

[6]
undefined -> "--------";

Contributor

chewbranca commented Aug 11, 2017

Overall I think this looks good, but I'm a bit confused as to why the nonce isn't getting logged already. We write the log entry in [1], which includes the MsgId in [2], and we set that value in [3] by way of [4]. This log statement is happening in rexi_server:init_p/3 which is already recording the nonce [5], so I'm a bit confused as to why the nonce is not showing up as expected, or even the fall back msg_id [6].

[1]

write(Entry, St) ->
#log_entry{
level = Level,
pid = Pid,
msg = Msg,
msg_id = MsgId,
time_stamp = TimeStamp
} = Entry,
Fmt = "<~B>~B ~s ~s ~s ~p ~s - ",
Args = [
St#st.facility bor get_level(Level),
?SYSLOG_VERSION,
TimeStamp,
St#st.hostname,
St#st.appid,
Pid,
MsgId
],
Pre = io_lib:format(Fmt, Args),
ok = send(St, [Pre, Msg, $\n]),
{ok, St}.

[2]
[3]
msg_id = couch_log_util:get_msg_id(),

[4]
case erlang:get(nonce) of

[5]
put(nonce, Nonce),

[6]
undefined -> "--------";

@iilyak

This comment has been minimized.

Show comment
Hide comment
@iilyak

iilyak Aug 14, 2017

Contributor

@chewbranca: You were right the Nonce shouldn't be part of a message. I just pushed the change which removes it. The nonce is added by couch_log_writer_syslog.erl to the syslog message. It can be accessed as %msgid from format pattern.

Contributor

iilyak commented Aug 14, 2017

@chewbranca: You were right the Nonce shouldn't be part of a message. I just pushed the change which removes it. The nonce is added by couch_log_writer_syslog.erl to the syslog message. It can be accessed as %msgid from format pattern.

@chewbranca

This comment has been minimized.

Show comment
Hide comment
@chewbranca

chewbranca Aug 16, 2017

Contributor

+1

Contributor

chewbranca commented Aug 16, 2017

+1

@iilyak iilyak merged commit b2397c5 into apache:master Aug 16, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@iilyak iilyak deleted the cloudant:91868-improve-log-from-rexi branch Aug 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment