-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathStudioLogger.cpp
46 lines (41 loc) · 2.52 KB
/
StudioLogger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "StudioLogger.h"
#include "Logging.h"
using namespace shapeworks;
//---------------------------------------------------------------------------
void StudioLogger::register_callbacks() {
auto error_callback = std::bind(&StudioLogger::handle_error, this, std::placeholders::_1);
Logging::Instance().set_error_callback(error_callback);
auto message_callback = std::bind(&StudioLogger::handle_message, this, std::placeholders::_1);
Logging::Instance().set_message_callback(message_callback);
auto warning_callback = std::bind(&StudioLogger::handle_warning, this, std::placeholders::_1);
Logging::Instance().set_warning_callback(warning_callback);
auto debug_callback = std::bind(&StudioLogger::handle_debug, this, std::placeholders::_1);
Logging::Instance().set_debug_callback(debug_callback);
auto status_callback = std::bind(&StudioLogger::handle_status, this, std::placeholders::_1);
Logging::Instance().set_status_callback(status_callback);
auto progress_callback =
std::bind(&StudioLogger::handle_progress, this, std::placeholders::_1, std::placeholders::_2);
Logging::Instance().set_progress_callback(progress_callback);
}
//---------------------------------------------------------------------------
StudioLogger::~StudioLogger() {
// unregister callbacks
Logging::Instance().set_error_callback(nullptr);
Logging::Instance().set_message_callback(nullptr);
Logging::Instance().set_warning_callback(nullptr);
Logging::Instance().set_debug_callback(nullptr);
Logging::Instance().set_status_callback(nullptr);
Logging::Instance().set_progress_callback(nullptr);
}
//---------------------------------------------------------------------------
void StudioLogger::handle_message(std::string str) { Q_EMIT message(str); }
//---------------------------------------------------------------------------
void StudioLogger::handle_error(std::string str) { Q_EMIT error(str); }
//---------------------------------------------------------------------------
void StudioLogger::handle_warning(std::string str) { Q_EMIT warning(str); }
//---------------------------------------------------------------------------
void StudioLogger::handle_debug(std::string str) { Q_EMIT debug(str); }
//---------------------------------------------------------------------------
void StudioLogger::handle_status(std::string str) { Q_EMIT status(str); }
//---------------------------------------------------------------------------
void StudioLogger::handle_progress(double value, std::string str) { Q_EMIT progress(static_cast<int>(value), str); }