Hi:

I have a rellly long process that produces about 700 Mb of a txt log output file. This is very hard to manage. So I want to divide the output in multiple smaller log files. This is what my main.cpp looks like

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "mineedit.h"
  3. #include "logoutput.h"
  4. #include <iostream>
  5.  
  6. void messageHandling(QtMsgType type, const char *msg){
  7.  
  8. if (ERRORLOGGER.isEmpty()){
  9. ERRORLOGGER = DEFERRORLOGGER;
  10. }
  11.  
  12. std::cout << "In Message Handling" << std::endl;
  13. std::cout << "Writing to file" << ERRORLOGGER.toStdString() << std::endl;
  14.  
  15. QFile file(ERRORLOGGER);
  16. file.open(QFile::Append);
  17. QTextStream stream(&file);
  18. switch (type) {
  19. case QtDebugMsg:
  20. stream << msg << "\n";
  21. file.close();
  22. break;
  23. case QtWarningMsg:
  24. stream << "WARNING: " << msg << "\n";
  25. file.close();
  26. break;
  27. case QtCriticalMsg:
  28. stream << "CRITICAL: " << msg << "\n";
  29. file.close();
  30. break;
  31. case QtFatalMsg:
  32. stream << "FATAL: " << msg << "\n";
  33. file.close();
  34. abort();
  35. }
  36. }
  37.  
  38. int main(int argc, char *argv[])
  39. {
  40. ERRORLOGGER = DEFERRORLOGGER;
  41. qInstallMsgHandler(messageHandling);
  42. QApplication a(argc, argv);
  43. MineEdit w;
  44. w.show();
  45. return a.exec();
  46. }
To copy to clipboard, switch view to plain text mode 

And my logoutput.h is like
Qt Code:
  1. #ifndef LOGOUTPUT_H
  2. #define LOGOUTPUT_H
  3.  
  4. #include <QString>
  5.  
  6. //----------------------------For outputting an error file--------------------------------
  7. #define DEFERRORLOGGER "/home/aarelovich/Documents/log.err"
  8. #define FOLDER_OUTPUT_LOG "./home/aarelovich/Documents"
  9. extern QString ERRORLOGGER;
  10.  
  11. #endif // LOGOUTPUT_H
To copy to clipboard, switch view to plain text mode 

Now in a part of my code I do:
ERRORLOGGER = name_of_current_log_file.

However I get the following compilation errors:
obj/main.o: In function `messageHandling(QtMsgType, char const*)':
/home/aarelovich/Dropbox/MineSim/main.cpp:8: undefined reference to `ERRORLOGGER'
/home/aarelovich/Dropbox/MineSim/main.cpp:9: undefined reference to `ERRORLOGGER'
/home/aarelovich/Dropbox/MineSim/main.cpp:13: undefined reference to `ERRORLOGGER'
/home/aarelovich/Dropbox/MineSim/main.cpp:15: undefined reference to `ERRORLOGGER'
obj/main.o: In function `main':
/home/aarelovich/Dropbox/MineSim/main.cpp:40: undefined reference to `ERRORLOGGER'
obj/mineedit.o:/home/aarelovich/Dropbox/MineSim/mineedit.cpp:101: more undefined references to `ERRORLOGGER' follow
collect2: ld returned 1 exit status

Can anyone please tell me what am I doing wrong? Or how I can dynamically change the output file in which I create my application log?

Thanks for any help