/**
 * 
*/

#include <RTSPyLogging.h>
#include <GILLock.h>





//RTSPyLogging::RTSPyLogging(PyObject* pPyLogging): mplogging(pPyLogging) 
RTSPyLogging::RTSPyLogging()
{}       
    
RTSPyLogging::~RTSPyLogging()
{}

void RTSPyLogging::log(std::string msg, PyObject* f){
        // GIL state handler
    PyLockGIL gstate;
    // Python callback
    call_method<void>(f, "log", msg);
    // GIL handler release
}

std::string RTSPyLogging::format(const std::string fmt_str, ...)
{
    va_list ap;
    char *fp = NULL;
    va_start(ap, fmt_str);
    vasprintf(&fp, fmt_str.c_str(), ap);
    va_end(ap);
    std::unique_ptr<char[]> formatted(fp);
    return std::string(formatted.get());
}
