Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions src/Console.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
/*
* Console.cpp
*
* Created on: 2014-10-16
* Author: Roger
*/
/#include "Console.h" // <-- ADD THIS
#include <QSettings> // <-- ADD THIS
#include "applicationui.hpp"
#include <bb/cascades/Application>
#include <QLocale>
#include <QTranslator>
#include <Qt/qdeclarativedebug.h>

#include "Console.h"
#include <QStringList>
#include <bb/ApplicationInfo>
using namespace bb::cascades;

Console::Console() :
QObject(),
m_socket(new QUdpSocket(this))
{
}
void myMessageOutput(QtMsgType type, const char* msg) { // <-- ADD THIS
Q_UNUSED(type); // <-- ADD THIS
fprintf(stdout, "%s\n", msg); // <-- ADD THIS
fflush(stdout); // <-- ADD THIS

Console::~Console()
{
m_socket->deleteLater();
}
QSettings settings; // <-- ADD THIS
if (settings.value("sendToConsoleDebug", true).toBool()) { // <-- ADD THIS -- Put this value to false if you want to stop sending logs to ConsoleDebug
Console* console = new Console(); // <-- ADD THIS
console->sendMessage("ConsoleThis$$" + QString(msg)); // <-- ADD THIS
console->deleteLater(); // <-- ADD THIS
} // <-- ADD THIS
} // <-- ADD THIS

void Console::sendMessage(QString _data)
Q_DECL_EXPORT int main(int argc, char **argv)
{
bb::ApplicationInfo appInfo;
QString message = appInfo.title() + "$$" + _data;
Application app(argc, argv);

qInstallMsgHandler(myMessageOutput); // <-- ADD THIS

m_socket->writeDatagram(message.toStdString().c_str(),QHostAddress("127.0.0.1"), CLIENT_SENDING_PORT);
...
}