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

Unify logging in libxrdp #1738

Merged
merged 4 commits into from
Dec 23, 2020
Merged

Conversation

aquesnel
Copy link
Contributor

Follow-on pull request to #1633 which migrates all logging in the libxrdp directory to use the LOG() and LOG_DEVEL() macros.

@aquesnel aquesnel changed the title Unify logging libxrdp Unify logging in libxrdp Nov 30, 2020
@aquesnel aquesnel force-pushed the unify_logging_libxrdp branch from 53f7571 to 2d6d249 Compare November 30, 2020 05:05
@matt335672
Copy link
Member

Nice work!

I'm not hugely familiar with this area of the code, but looking at your PR makes me realise this is well worth doing.

The only comment I've got is similar to one I made on #1738. Where there's currently an output produced by g_writeln and friends, I'd rather see that replaced in the short term at least by a LOG( macro rather than a LOG_DEVEL( macro. I appreciate that many of these may not make a lot of sense to a sysadmin, but at the moment there's a chance of a silent fail which is harder for us to diagnose if it happens.

Please come back to me on that if you've got a strong opinion on this. Also there are a few commented out g_writeln() calls and I absolutely think you've done the right thing there.

This looks like pretty much a straight text subs to me. I can see why you've introduced UNUSED_VAR, and I think you've got the best solution to that problem. You could use compiler variable attributes but these aren't necessarily portable.

As ever, thanks very much for your contributions.

@aquesnel
Copy link
Contributor Author

ok, I'll review the log changes to avoid silent failures.

@aquesnel
Copy link
Contributor Author

aquesnel commented Dec 5, 2020

Hi @matt335672 ,

I've modified the log messages in error code paths to use LOG instead of LOG_DEVEL. Please let me know if there is additional logging lines that you think should have different log levels or log macros.

Since we are discussing log messages, I also want to mention that I've made pull request #1742 which adds on top of this pull request more detailed and clear logging messages in the libxrdp code. I created it as a separate pull request to separate the text substitution from improving the log messages.

Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

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

A few minor comments for your consideration

self->client_info.jpeg_codec_id = codec_id;
i1 = MIN(64, codec_properties_length);
g_memcpy(self->client_info.jpeg_prop, s->p, i1);
self->client_info.jpeg_prop_len = i1;
/* make sure that requested quality is between 0 to 100 */
if (self->client_info.jpeg_prop[0] < 0 || self->client_info.jpeg_prop[0] > 100)
{
g_writeln(" Warning: the requested jpeg quality (%d) is invalid,"
LOG_DEVEL(LOG_LEVEL_WARNING, " Warning: the requested jpeg quality (%d) is invalid,"
Copy link
Member

Choose a reason for hiding this comment

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

Should this be LOG() ?

Comment on lines 462 to 463
LOG(LOG_LEVEL_ERROR, "out xrdp_rdp_recv error");
LOG(LOG_LEVEL_ERROR, "xrdp_rdp_recv: xrdp_sec_recv failed");
Copy link
Member

Choose a reason for hiding this comment

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

Probably can remove one of these

Comment on lines 688 to 689
LOG(LOG_LEVEL_ERROR, "xrdp_sec_process_logon_info: flags wrong, major error");
LOG(LOG_LEVEL_ERROR, "xrdp_sec_process_logon_info: flags wrong, likely decrypt "
Copy link
Member

Choose a reason for hiding this comment

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

Probably can remove one of these

Comment on lines 1255 to 1256
LOG(LOG_LEVEL_ERROR, " out xrdp_sec_recv : error");
LOG(LOG_LEVEL_ERROR, "xrdp_sec_recv: xrdp_mcs_recv failed");
Copy link
Member

Choose a reason for hiding this comment

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

Probably can remove one of these

@matt335672
Copy link
Member

Really good stuff BTW - I can see where some real thought has gone in to some of these.

@metalefty - given this is general substitution (plus of course the re-formatting), I'm happy to merge this. Let me know what you think.

@metalefty metalefty added this to the v0.9.15 milestone Dec 11, 2020
@aquesnel
Copy link
Contributor Author

I've implemented @matt335672 recommendations, and I think this is ready to merge. Please let me know if there is anything else that needs to be cleaned up or squashed before merging.

@@ -135,18 +131,18 @@ libxrdp_force_read(struct trans* trans)

if (trans_force_read(trans, 4) != 0)
{
g_writeln("libxrdp_force_read: header read error");
LOG(LOG_LEVEL_WARNING, "libxrdp_force_read: header read error");
Copy link
Member

Choose a reason for hiding this comment

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

Thank you very much for your careful work! You did this not just by replacing them with a single log level but considered the log context.

{
/* certificate or privkey is not readable */
log_message(LOG_LEVEL_DEBUG, "No readable certificates or "
"private keys, cannot accept TLS connections");
LOG(LOG_LEVEL_WARNING, "No readable certificates or "
Copy link
Member

Choose a reason for hiding this comment

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

Good catch.

@metalefty
Copy link
Member

Let's merge.

@metalefty metalefty merged commit bba65b3 into neutrinolabs:devel Dec 23, 2020
@aquesnel aquesnel deleted the unify_logging_libxrdp branch December 23, 2020 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants