-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add custom logger capabilities #180
Open
bwrsandman
wants to merge
2
commits into
twogood:main
Choose a base branch
from
bwrsandman:log-handler
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
Conversation
This file contains 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
bwrsandman
added a commit
to bwrsandman/openblack
that referenced
this pull request
Jan 3, 2024
Example use of custom logger using spdlog in c++ void unshield_log_handler([[maybe_unused]] void* userdata, int level, const char* file, int line, const char* format, va_list args)
{
spdlog::level::level_enum spdlogLevel;
switch (level)
{
case UNSHIELD_LOG_LEVEL_TRACE:
spdlogLevel = spdlog::level::trace;
break;
case UNSHIELD_LOG_LEVEL_WARNING:
spdlogLevel = spdlog::level::warn;
break;
case UNSHIELD_LOG_LEVEL_ERROR:
spdlogLevel = spdlog::level::err;
break;
}
// Get the length of the message
va_list args_copy;
va_copy(args_copy, args);
int length = vsnprintf(nullptr, 0, format, args_copy) + 1;
va_end(args_copy);
std::vector<char> message(length);
vsnprintf(message.data(), message.size(), format, args);
SPDLOG_LOGGER_CALL(spdlog::get("filesystem"), spdlogLevel, "unshield: {}", message.data());
} |
bwrsandman
force-pushed
the
log-handler
branch
2 times, most recently
from
January 3, 2024 06:42
a97300a
to
6da5ca2
Compare
bwrsandman
added a commit
to bwrsandman/openblack
that referenced
this pull request
Jan 3, 2024
7 tasks
@bwrsandman sorry about the merge conflict! |
Default to old stderr logging method. Add function pointer and userdata pointer as static globals.
bwrsandman
force-pushed
the
log-handler
branch
from
January 3, 2024 16:35
6da5ca2
to
72066ff
Compare
rebased! |
bwrsandman
added a commit
to bwrsandman/openblack
that referenced
this pull request
Jan 3, 2024
bwrsandman
added a commit
to bwrsandman/openblack
that referenced
this pull request
Jan 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add levels to public API.
Default to old stderr logging method.
Add function pointer and userdata pointer as static globals.
Implements #179