mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
add a message handler to send messages over to LogDisplay
This commit is contained in:
parent
89d3cfdb6f
commit
51d1e6ae80
4 changed files with 15 additions and 8 deletions
|
@ -164,6 +164,11 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
|
||||||
Application::getInstance()->wheelEvent(event);
|
Application::getInstance()->wheelEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void messageHandler(QtMsgType type, const char* message) {
|
||||||
|
printf("%s\n", message);
|
||||||
|
LogDisplay::instance.addMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
QApplication(argc, argv),
|
QApplication(argc, argv),
|
||||||
_window(new QMainWindow(desktop())),
|
_window(new QMainWindow(desktop())),
|
||||||
|
@ -212,6 +217,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_window->setWindowTitle("Interface");
|
_window->setWindowTitle("Interface");
|
||||||
qDebug("Interface Startup:");
|
qDebug("Interface Startup:");
|
||||||
|
|
||||||
|
qInstallMsgHandler(messageHandler);
|
||||||
|
|
||||||
unsigned int listenPort = 0; // bind to an ephemeral port by default
|
unsigned int listenPort = 0; // bind to an ephemeral port by default
|
||||||
const char** constArgv = const_cast<const char**>(argv);
|
const char** constArgv = const_cast<const char**>(argv);
|
||||||
const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
|
const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
FILE* const LogDisplay::DEFAULT_STREAM = stdout;
|
FILE* const LogDisplay::DEFAULT_STREAM = 0l;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Singleton constructor
|
// Singleton constructor
|
||||||
|
@ -88,7 +88,7 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) {
|
||||||
// Logging
|
// Logging
|
||||||
//
|
//
|
||||||
|
|
||||||
inline void LogDisplay::addMessage(char const* ptr) {
|
void LogDisplay::addMessage(const char* ptr) {
|
||||||
|
|
||||||
pthread_mutex_lock(& _mutex);
|
pthread_mutex_lock(& _mutex);
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ public:
|
||||||
|
|
||||||
void render(unsigned screenWidth, unsigned screenHeight);
|
void render(unsigned screenWidth, unsigned screenHeight);
|
||||||
|
|
||||||
// log formatted message
|
// log formatted message
|
||||||
inline void addMessage(char const*);
|
void addMessage(const char* message);
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
|
||||||
if (!_sharedInstance) {
|
if (!_sharedInstance) {
|
||||||
_sharedInstance = new NodeList(ownerType, socketListenPort);
|
_sharedInstance = new NodeList(ownerType, socketListenPort);
|
||||||
} else {
|
} else {
|
||||||
qDebug("NodeList createInstance called with existing instance.");
|
qDebug("NodeList createInstance called with existing instance.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return _sharedInstance;
|
return _sharedInstance;
|
||||||
|
@ -51,7 +51,7 @@ NodeList* NodeList::createInstance(char ownerType, unsigned int socketListenPort
|
||||||
|
|
||||||
NodeList* NodeList::getInstance() {
|
NodeList* NodeList::getInstance() {
|
||||||
if (!_sharedInstance) {
|
if (!_sharedInstance) {
|
||||||
qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.");
|
qDebug("NodeList getInstance called before call to createInstance. Returning NULL pointer.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return _sharedInstance;
|
return _sharedInstance;
|
||||||
|
@ -275,9 +275,9 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
sockaddr_in tempAddress;
|
sockaddr_in tempAddress;
|
||||||
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
||||||
strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr));
|
strcpy(_domainIP, inet_ntoa(tempAddress.sin_addr));
|
||||||
qDebug("Domain Server: %s ", _domainHostname);
|
qDebug("Domain Server: %s", _domainHostname);
|
||||||
} else {
|
} else {
|
||||||
qDebug("Failed domain server lookup");
|
qDebug("Failed domain server lookup\n");
|
||||||
}
|
}
|
||||||
} else if (!printedDomainServerIP) {
|
} else if (!printedDomainServerIP) {
|
||||||
qDebug("Domain Server IP: %s", _domainIP);
|
qDebug("Domain Server IP: %s", _domainIP);
|
||||||
|
|
Loading…
Reference in a new issue