feat: add logger on TINYMITM_LOGS builds
This commit is contained in:
@@ -21,6 +21,12 @@
|
||||
|
||||
#include "raai-helper.h"
|
||||
|
||||
#ifdef TINYMITM_LOGS
|
||||
#define TINYMITM_WRITELOG(type, ...) _log->type(...)
|
||||
#else
|
||||
#define TINYMITM_WRITELOG()
|
||||
#endif
|
||||
|
||||
/*
|
||||
RAAI helpers
|
||||
*/
|
||||
@@ -113,6 +119,7 @@ void setNonBlocking(SOCKET s)
|
||||
TinyMITMProxy::~TinyMITMProxy()
|
||||
{
|
||||
shutdown();
|
||||
delete _log;
|
||||
}
|
||||
|
||||
bool TinyMITMProxy::init()
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include <seallib/events.h>
|
||||
|
||||
#if TINYMITM_LOGS
|
||||
#include <seallib/log.h>
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <queue>
|
||||
@@ -51,7 +55,12 @@ struct TinyMITMConfig
|
||||
class TinyMITMProxy
|
||||
{
|
||||
public:
|
||||
TinyMITMProxy(TinyMITMConfig config) : _config(std::move(config)) {}
|
||||
TinyMITMProxy(TinyMITMConfig config) : _config(std::move(config))
|
||||
{
|
||||
#ifdef TINYMITM_LOGS
|
||||
_log = new seallib::Logger("TinyMITMProxy");
|
||||
#endif
|
||||
}
|
||||
~TinyMITMProxy();
|
||||
|
||||
bool init();
|
||||
@@ -85,6 +94,10 @@ class TinyMITMProxy
|
||||
*/
|
||||
seallib::Event<const std::string&, std::string&, std::string&, bool> onServerResponse;
|
||||
|
||||
#ifdef TINYMITM_LOGS
|
||||
void addLogSink(std::shared_ptr<seallib::ILogSink> sink) { _log->addSink(std::move(sink)); }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// helper functions
|
||||
static long long stollSafe(const std::string& s, int def = 0, int base = 10);
|
||||
@@ -117,4 +130,8 @@ class TinyMITMProxy
|
||||
CertificateManager _certManager;
|
||||
|
||||
TinyMITMConfig _config;
|
||||
|
||||
#ifdef TINYMITM_LOGS
|
||||
seallib::Logger* _log;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user