-
Notifications
You must be signed in to change notification settings - Fork 2
Optimize and add ability to configure error printing function #11
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
Open
rayhamel
wants to merge
14
commits into
cjdb:main
Choose a base branch
from
rayhamel:ConfigurableErrorPrinting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a020752
Optimize and add ability to configure error printing function
rayhamel ba09c4b
Make parameters to print functions const, for consistency
rayhamel 732627c
Use operator<< instead of ostream::write for string_view
rayhamel c369831
'invert' and eliminate repeated code in the stdio and iostream print_…
rayhamel e006adb
Switch back to ostream::write
rayhamel 0d28933
Change error printing customization point to a variable (function poi…
rayhamel 92914b2
Add tests for iostream output
rayhamel 4264c17
Make clang-tidy happy with namespace closing comment
rayhamel 09d4baf
Make print_error an inline variable to silence clang-tidy warning
rayhamel 43b4f9a
Define a stub for cjdb::print_error even when CJDB_SKIP_STDIO is defi…
rayhamel 6977cc1
Update documentation
rayhamel d553310
Minor formatting change
rayhamel e2bc28d
Another formatting change
rayhamel 539b14e
Deleted asterisk, misc formatting
rayhamel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is this guard protecting against?
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.
My idea is that the user could optionally define their own
CJDB_PRINT_ERROR
function.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.
cjdb::contracts_detail
is a detail namespace, so a user can't do this under the proposed model. If you want to make this configurable, please put it in namespacecjdb
. I think the macro should probably be opt-out, not opt-in? Otherwise folks won't get any output in their debug builds, which would be surprising.Uh oh!
There was an error while loading. Please reload this page.
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.
My idea is that the user could define or choose an appropriate function under whichever namespace, then define the function-like macro
CJDB_PRINT_ERROR
to call that function. Thecjdb::contracts_detail::print_error
function is only created whenCJDB_PRINT_ERROR
is not already defined.There may of course be better ways of making this configurable.
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.
Could you please have a think about a more C++-oriented way to configure this? You don't need to implement it just yet: come back here and post the idea, but if we can avoid a macro, that'd be great.
Uh oh!
There was an error while loading. Please reload this page.
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.
I changed the implementation to use a function pointer
cjdb::print_error
which the user can set to something else. I still do have two macro configuration optionsCJDB_USE_IOSTREAM
(as you know,#include <iostream>
introduces some overhead, so should be opt-in) andCJDB_SKIP_STDIO
, in which case there's also no dependency oncstdio
and the user must provide their own definition forcjdb::print_error
.