[C++-sig] calling python logger module from C++
Eric
cppsig-eric at sneakemail.com
Thu May 12 05:19:00 CEST 2005
I've been wondering how best to provide support for calling my python logger
(which uses the standard logger module) from within my C++ extensions built
using Boost.Python. My first thought was to do this:
enum LogLevel {
LogLevelCritical = 50,
LogLevelError = 40,
LogLevelWarning = 30,
LogLevelInfo = 20,
LogLevelDebug = 10
};
class PiLogger {
public:
virtual void Log( LogLevel level, std::wstring msg ) = 0;
};
and then implement this class in python, setting it as a static variable in
my C++. This works pretty well, but I'd like to be able to support format
strings, which requires varargs. I couldn't figure out how to wrap a varargs
function - is that even possible? If it's not, is there a better way to
accomplish what I want?
Thanks,
Eric
More information about the Cplusplus-sig
mailing list