aboutsummaryrefslogtreecommitdiffstats
path: root/serd/serd.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'serd/serd.hpp')
-rw-r--r--serd/serd.hpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/serd/serd.hpp b/serd/serd.hpp
index 5084e1ad..112daa23 100644
--- a/serd/serd.hpp
+++ b/serd/serd.hpp
@@ -574,12 +574,6 @@ struct Message
/**
@}
- @name Event Handlers
- @{
-*/
-
-/**
- @}
@name World
@{
*/
@@ -601,11 +595,6 @@ public:
serd_world_set_message_sink(cobj(), s_message_sink, this);
}
- Status log(const SerdMessage* msg)
- {
- return static_cast<Status>(serd_world_log(cobj(), msg));
- }
-
SERD_LOG_FUNC(5, 6)
Status log(const Status status,
const LogLevel level,
@@ -615,44 +604,49 @@ public:
{
va_list args;
va_start(args, fmt);
- const SerdMessage msg = {static_cast<SerdStatus>(status),
- static_cast<SerdLogLevel>(level),
- cursor,
- fmt,
- &args};
- const SerdStatus st = serd_world_log(cobj(), &msg);
+
+ const SerdStatus st = serd_world_vlogf(cobj(),
+ static_cast<SerdStatus>(status),
+ static_cast<SerdLogLevel>(level),
+ cursor,
+ fmt,
+ args);
va_end(args);
return static_cast<Status>(st);
}
private:
- static std::string format(const char* fmt, va_list* args) noexcept
+ static std::string format(const char* fmt, va_list args) noexcept
{
va_list args_copy;
- va_copy(args_copy, *args);
+ va_copy(args_copy, args);
const int n_bytes = vsnprintf(nullptr, 0, fmt, args_copy);
va_end(args_copy);
#if __cplusplus >= 201703L
std::string result(n_bytes, '\0');
- vsnprintf(result.data(), n_bytes + 1, fmt, *args);
+ vsnprintf(result.data(), n_bytes + 1, fmt, args);
#else
std::vector<char> str(n_bytes + 1U, '\0');
- vsnprintf(str.data(), n_bytes + 1U, fmt, *args);
+ vsnprintf(str.data(), n_bytes + 1U, fmt, args);
std::string result(str.data(), size_t(n_bytes));
#endif
return result;
}
- static SerdStatus
- s_message_sink(void* handle, const SerdMessage* msg) noexcept
+ static SerdStatus s_message_sink(void* handle,
+ SerdStatus status,
+ SerdLogLevel level,
+ const SerdCursor* cursor,
+ const char* fmt,
+ va_list args) noexcept
{
const auto* const self = static_cast<const World*>(handle);
try {
- Message message{static_cast<Status>(msg->status),
- static_cast<LogLevel>(msg->level),
- CursorView{msg->cursor},
- format(msg->fmt, msg->args)};
+ Message message{static_cast<Status>(status),
+ static_cast<LogLevel>(level),
+ CursorView{cursor},
+ format(fmt, args)};
return static_cast<SerdStatus>(self->_msg_sink(message));
} catch (...) {
return SERD_ERR_INTERNAL;