|
|
|
@ -13,6 +13,7 @@ |
|
|
|
|
#include <QtGui/QDialog> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#include <stdexcept> |
|
|
|
|
#include <sstream> |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <iomanip> |
|
|
|
@ -29,8 +30,6 @@ namespace qbrowserlib { |
|
|
|
|
#ifndef LOG |
|
|
|
|
#define LOG \ |
|
|
|
|
QBROWSERLIB_LOCAL_TRACER |
|
|
|
|
// #define LOG
|
|
|
|
|
// qbrowserlib::Log(1, __PRETTY_FUNCTION__, __FILE__, __LINE__)
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef TRC |
|
|
|
@ -45,6 +44,29 @@ namespace qbrowserlib { |
|
|
|
|
(0, __PRETTY_FUNCTION__, __FILE__, __LINE__) |
|
|
|
|
#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 Log { |
|
|
|
@ -56,7 +78,8 @@ namespace qbrowserlib { |
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
@ -79,6 +102,7 @@ namespace qbrowserlib { |
|
|
|
|
static LogDialog* _dialog; |
|
|
|
|
static unsigned int _level; |
|
|
|
|
bool _debug; |
|
|
|
|
bool _close; |
|
|
|
|
const void* _addr; |
|
|
|
|
const std::string _name; |
|
|
|
|
const std::string _file; |
|
|
|
@ -193,11 +217,11 @@ namespace qbrowserlib { |
|
|
|
|
template<typename TYPE> Log& Log::operator<<(TYPE arg) { |
|
|
|
|
if (!_debug) return *this; |
|
|
|
|
std::stringstream ss; |
|
|
|
|
init(ss); |
|
|
|
|
// init(ss);
|
|
|
|
|
indent(ss)<<" → "<<arg; |
|
|
|
|
std::clog<<close(ss).str()<<std::endl; |
|
|
|
|
// std::clog<<close(ss).str()<<std::endl;
|
|
|
|
|
if (!_dialog) _dialog = new LogDialog; |
|
|
|
|
_dialog->append(*this, arg); |
|
|
|
|
_dialog->append(*this, ss.str()); |
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|