You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to figure out a nice way to use quill from C code that uses C++ API. Main intention is to replace old vprinft-based logging implementation with quill.
I added quill logger into c++ side and configured it it there and it starts and configures ok. But I was able to get it working only if pass only the ready formatted string (const *char) to C++ side losing the varargs.
So this works
// QLogger is just a wrapper for quill::logger
void LOGINFO_MSG(QLogger *qLogger, const char *formattedData)
{
auto logger = qLogger->getLogger();
// LOG_INFO does not seem to accept only const char*
//LOG_INFO(logger, formattedData);
// this does the trick though
LOG_INFO(logger, "{}", formattedData);
}
and is can be used like this:
void Log(const char *fmt, ...) {
va_list argptr;
// just some test buffer from stack
char buffer[1024];
va_start(argptr, fmt);
vsprintf_s(&buffer, sizeof(buffer), fmt, argptr);
LOGINFO_MSG(StoredLoggerPtr, buffer);
va_end(argptr);
}
What I would have wanted is to be able to expose the LOG_INFO api with varargs but was not able to figure out how to do this. I am no expert in varargs but I think I tried many things for this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am trying to figure out a nice way to use quill from C code that uses C++ API. Main intention is to replace old vprinft-based logging implementation with quill.
I added quill logger into c++ side and configured it it there and it starts and configures ok. But I was able to get it working only if pass only the ready formatted string (const *char) to C++ side losing the varargs.
So this works
and is can be used like this:
What I would have wanted is to be able to expose the LOG_INFO api with varargs but was not able to figure out how to do this. I am no expert in varargs but I think I tried many things for this.
Any ideas how to do this?
-antti
Beta Was this translation helpful? Give feedback.
All reactions