|
|
@ -13,6 +13,7 @@ |
|
|
|
#include <QtGui/QDialog> |
|
|
|
#include <QtGui/QDialog> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdexcept> |
|
|
|
#include <sstream> |
|
|
|
#include <sstream> |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include <iomanip> |
|
|
|
#include <iomanip> |
|
|
@ -29,8 +30,6 @@ namespace qbrowserlib { |
|
|
|
#ifndef LOG |
|
|
|
#ifndef LOG |
|
|
|
#define LOG \ |
|
|
|
#define LOG \ |
|
|
|
QBROWSERLIB_LOCAL_TRACER |
|
|
|
QBROWSERLIB_LOCAL_TRACER |
|
|
|
// #define LOG
|
|
|
|
|
|
|
|
// qbrowserlib::Log(1, __PRETTY_FUNCTION__, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef TRC |
|
|
|
#ifndef TRC |
|
|
@ -45,6 +44,29 @@ namespace qbrowserlib { |
|
|
|
(0, __PRETTY_FUNCTION__, __FILE__, __LINE__) |
|
|
|
(0, __PRETTY_FUNCTION__, __FILE__, __LINE__) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CRYPTOKI_LOG(X) \ |
|
|
|
|
|
|
|
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PCSC_LOG(X) \ |
|
|
|
|
|
|
|
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define OPENSSL_LOG(X) \ |
|
|
|
|
|
|
|
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define OPENSSL_CHECK(X) \ |
|
|
|
|
|
|
|
if (!X) { \
|
|
|
|
|
|
|
|
ERR_load_ENGINE_strings(); \
|
|
|
|
|
|
|
|
std::stringstream ss; \
|
|
|
|
|
|
|
|
for (unsigned int err(0); err=ERR_get_error();) { \
|
|
|
|
|
|
|
|
ss<<"Error: "<<ERR_error_string(err, 0)<<"; "; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
ss<<"Command "<<#X<<" failed in function "<<__PRETTY_FUNCTION__ \
|
|
|
|
|
|
|
|
<<" in file "<<__FILE__<<":"<<__LINE__; \
|
|
|
|
|
|
|
|
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false) \
|
|
|
|
|
|
|
|
<<ss.str(); \
|
|
|
|
|
|
|
|
throw std::runtime_error(ss.str()); \
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class LogDialog; |
|
|
|
class LogDialog; |
|
|
|
|
|
|
|
|
|
|
|
class Log { |
|
|
|
class Log { |
|
|
@ -56,7 +78,8 @@ namespace qbrowserlib { |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
Log(const void* addr, const std::string& name, |
|
|
|
Log(const void* addr, const std::string& name, |
|
|
|
const std::string& file, unsigned long line); |
|
|
|
const std::string& file, unsigned long line, |
|
|
|
|
|
|
|
bool traceOpenClose=true); |
|
|
|
|
|
|
|
|
|
|
|
template<typename TYPE> Log& operator<<(TYPE arg); |
|
|
|
template<typename TYPE> Log& operator<<(TYPE arg); |
|
|
|
|
|
|
|
|
|
|
@ -79,6 +102,7 @@ namespace qbrowserlib { |
|
|
|
static LogDialog* _dialog; |
|
|
|
static LogDialog* _dialog; |
|
|
|
static unsigned int _level; |
|
|
|
static unsigned int _level; |
|
|
|
bool _debug; |
|
|
|
bool _debug; |
|
|
|
|
|
|
|
bool _close; |
|
|
|
const void* _addr; |
|
|
|
const void* _addr; |
|
|
|
const std::string _name; |
|
|
|
const std::string _name; |
|
|
|
const std::string _file; |
|
|
|
const std::string _file; |
|
|
@ -193,11 +217,11 @@ namespace qbrowserlib { |
|
|
|
template<typename TYPE> Log& Log::operator<<(TYPE arg) { |
|
|
|
template<typename TYPE> Log& Log::operator<<(TYPE arg) { |
|
|
|
if (!_debug) return *this; |
|
|
|
if (!_debug) return *this; |
|
|
|
std::stringstream ss; |
|
|
|
std::stringstream ss; |
|
|
|
init(ss); |
|
|
|
// init(ss);
|
|
|
|
indent(ss)<<" → "<<arg; |
|
|
|
indent(ss)<<" → "<<arg; |
|
|
|
std::clog<<close(ss).str()<<std::endl; |
|
|
|
// std::clog<<close(ss).str()<<std::endl;
|
|
|
|
if (!_dialog) _dialog = new LogDialog; |
|
|
|
if (!_dialog) _dialog = new LogDialog; |
|
|
|
_dialog->append(*this, arg); |
|
|
|
_dialog->append(*this, ss.str()); |
|
|
|
return *this; |
|
|
|
return *this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|