refs #350 Changed log severity and log category in core as discussed

This commit is contained in:
Klaus Basan
2014-12-17 18:35:09 +01:00
parent 8a43efca92
commit d80f416752
3 changed files with 21 additions and 31 deletions

View File

@@ -33,16 +33,19 @@ using namespace BlackCore;
*/
int main(int argc, char *argv[])
{
// metadata are registered in runtime
QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412
CLogHandler::instance()->install();
CLogHandler::instance()->enableConsoleOutput(false); // default disable
QIcon icon(BlackMisc::CIcons::swiftNova24());
QApplication::setWindowIcon(icon);
CRuntime::registerMetadata(); // register metadata
QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412
QTextStream cin(stdin);
QTextStream cout(stdout);
cout << BlackMisc::CProject::version() << " " << BlackMisc::CProject::compiledInfo() << endl;
QIcon icon(BlackMisc::CIcons::swiftNova24());
QApplication::setWindowIcon(icon);
CLogHandler::instance()->install();
CLogHandler::instance()->enableConsoleOutput(false); // default disable
CLogHandler::instance()->handlerForPattern(
CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo)
)->enableConsoleOutput(true); // enable for info
cout << "1 + la/ra .. session DBus server (default)" << endl;
cout << "2 + la/ra .. system DBus server" << endl;
@@ -50,7 +53,6 @@ int main(int argc, char *argv[])
cout << "la .. local audio, audio runs in this core here (default)" << endl;
cout << "ra .. remote audio, audio runs in the GUI or elsewhere" << endl;
cout << "x .. exit" << endl;
QString input = cin.readLine().toLower().trimmed();
// configure DBus server
@@ -73,12 +75,14 @@ int main(int argc, char *argv[])
// with remote audio
bool remoteAudio = input.contains("ra");
CRuntime *core = remoteAudio ?
new CRuntime(CRuntimeConfig::forCoreAllLocalInDBusNoAudio(dBusAddress), &a) :
new CRuntime(CRuntimeConfig::forCoreAllLocalInDBus(dBusAddress), &a);
CRuntime *coreRuntime = remoteAudio ?
new CRuntime(CRuntimeConfig::forCoreAllLocalInDBusNoAudio(dBusAddress), &a) :
new CRuntime(CRuntimeConfig::forCoreAllLocalInDBus(dBusAddress), &a);
// tool to allow input indepent from event loop
QtConcurrent::run(BlackMiscTest::Tool::serverLoop, core); // QFuture<void> future
cout << "Will start server loop ... " << endl;
QFuture<void> future = QtConcurrent::run(BlackMiscTest::Tool::serverLoop, coreRuntime);
Q_UNUSED(future);
cout << "Server event loop, pid: " << BlackMiscTest::Tool::getPid() << " Thread id: " << QThread::currentThreadId() << endl;
// end

View File

@@ -24,27 +24,18 @@ using namespace BlackMisc::Audio;
namespace BlackMiscTest
{
/*
* Start a new process
*/
QProcess *Tool::startNewProcess(const QString &executable, const QStringList &arguments, QObject *parent)
{
QProcess *process = new QProcess(parent);
process->startDetached(executable, arguments);
return process;
}
/*
* Send data to testservice, this sends data to the slots on the server
*/
void Tool::serverLoop(CRuntime *runtime)
{
QMetaObject::invokeMethod(CLogHandler::instance(), "enableConsoleOutput", Q_ARG(bool, false));
QTextStream qtout(stdout);
qtout << "Running on server here " << Tool::getPid() << " thread: " << QThread::currentThreadId() << endl;
Q_ASSERT(runtime);
QThread::sleep(3); // let the DBus server startup
QThread::sleep(3); // time in secs, let the DBus server startup
// log
// log initial severity
CLogSubscriber applicationMessageSubscriber, audioMessageSubscriber, networkMessageSubscriber, ownAircraftMessageSubscriber, settingsMessageSubscriber, simulatorMessageSubscriber;
CStatusMessage::StatusSeverity messageSeverity = CStatusMessage::SeverityInfo;
auto refreshSubscriptionSeverities = [ & ]()
@@ -56,10 +47,8 @@ namespace BlackMiscTest
settingsMessageSubscriber.changeSubscription(CLogPattern::allOf(runtime->getIContextSettings()).withSeverityAtOrAbove(messageSeverity));
simulatorMessageSubscriber.changeSubscription(CLogPattern::allOf(runtime->getIContextSimulator()).withSeverityAtOrAbove(messageSeverity));
};
refreshSubscriptionSeverities();
QTextStream qtout(stdout);
qtout << "Running on server here " << Tool::getPid() << " thread: " << QThread::currentThreadId() << endl;
refreshSubscriptionSeverities();
//
// Server loop

View File

@@ -25,9 +25,6 @@ namespace BlackMiscTest
return QCoreApplication::applicationPid();
}
//! Start a new process
static QProcess *startNewProcess(const QString &executable, const QStringList &arguments = QStringList(), QObject *parent = 0);
//! Server loop
static void serverLoop(BlackCore::CRuntime *runtime);