--- /dev/null
+//
+// C++ Implementation: debug
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "debug.h"
+#include "main.h"
+
+#include <QCoreApplication>
+#include <QDateTime>
+#include <QDir>
+#include <QFile>
+
+static QFile*mylogFile=0;
+
+static void mymsghandler(QtMsgType, const char *msg)
+{
+ if(mylogFile){
+ mylogFile->write(msg,strlen(msg));
+ mylogFile->write("\n",1);
+ mylogFile->flush();
+ }
+#ifdef Q_OS_UNIX
+ fprintf(stderr,"%s\n",msg);
+#endif
+}
+
+void initDebug()
+{
+ QDir(dataDir).mkdir("debuglog");
+ mylogFile=new QFile(dataDir+"/debuglog/log-"+QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss.zzz")+".txt");
+ if(mylogFile->open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text)){
+ qInstallMsgHandler(mymsghandler);
+ }else{
+ delete mylogFile;
+ mylogFile=0;
+ qDebug("Failed to install debuglog.");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+//
+// C++ Interface: debug
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_DEBUG_H
+#define MAGICSMOKE_DEBUG_H
+
+void initDebug();
+
+#endif
#include "mainwindow.h"
#include "hmac.h"
#include "main.h"
+#include "debug.h"
QString choseLanguage(bool warn)
{
//try to find data dir
initDataDir();
+ //initialize log file
+ initDebug();
+
//check/generate host settings
if(!QSettings().contains("hostkey")){
MKeyGen mkg;
#ifndef MAGICSMOKE_MAIN_H
#define MAGICSMOKE_MAIN_H
+#include <QString>
+
QString choseLanguage(bool warn=true);
extern QString dataDir;