-
Notifications
You must be signed in to change notification settings - Fork 284
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
Split daemon's logging backends in separate modules #487
Conversation
@Zer0-One says that I might be over-engineering it with this PR, as there is no reason for having more than two backends -- one for running in foreground (stdout) and one for the background (syslog). I still think that putting stdout/syslog into separate files makes If you really insist that it's over-engineering, I could compromise on keeping stdout and syslog bakends in separate files, but removing the the support for adding additional logging backends: remove |
I like your second suggestion more, but IMO this is simple enough to keep within a single module. |
|
||
#include <stdarg.h> | ||
|
||
typedef struct Log_Backend_Impl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this can be moved to the .c file. It's used only once.
Check the checkbox for collaborator pushes. |
Checked. |
I'm ok with this change. In fact, I really don't care about the bootstrap daemon's logging backend design. Are we going to merge this? |
Oh, totally forgot about this PR. I guess I have to modify the code to the compromise I have described in #487 (comment). |
d1664a1
to
b306af7
Compare
@Zer0-One does the last commit look better? If so, I will squash the commits. |
|
@nurupo travis is happy. Can you squash the commits? |
ed2aee0
to
b0aec02
Compare
Done. |
Review status: 0 of 11 files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
log_backend.h
defines an interface for logging back-ends, whichlog_backend_[stdout|syslog].[h|c]
implement. These implementations are then put together into aBACKENDS
array inlog.c
, which is indexed by theLOG_BACKEND
enum. Haven't really done any such modular implementations in C before, so any corrections are welcome.Renamed
open_log()
-->log_open()
close_log()
-->log_close()
write_log()
-->log_write()
Should probably have been a separate commit/PR, but I happened to do the renaming and modularization at the same time, so there we go.
I meant to make logging modular from the beginning, but at the time of writing it I thought that maybe it's simpler to keep all logging backends relatively separate in
log.c
as there is so little code, instead of scattering them in multiple files and adding this struct with function pointers glue, at least until there is more code for the logging that would warrant the splitting, but there was some confusion as to why I want to keep backends relatively separate, so this PR should remove this confusion now that the logging backends are truly separate.
This change is