Changeset 109 in ntrip for trunk/BNC


Ignore:
Timestamp:
Sep 7, 2006, 10:30:58 AM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncapp.cpp

    r96 r109  
    1616 * -----------------------------------------------------------------------*/
    1717
    18 #include <QFile>
    19 #include <QTextStream>
    2018#include <iostream>
    2119
     
    2826bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
    2927  QApplication(argc, argv, GUIenabled) {
     28
     29  _logFile   = 0;
     30  _logStream = 0;
     31  for (int ii = 1; ii < argc; ii++) {
     32    if (QString(argv[ii]) == "-o" && ii+1 < argc) {
     33      _logFile = new QFile(argv[ii+1]);
     34      _logFile->open(QIODevice::WriteOnly);
     35      _logStream = new QTextStream();
     36      _logStream->setDevice(_logFile);
     37    }
     38  }
    3039}
    3140
     
    3342////////////////////////////////////////////////////////////////////////////
    3443bncApp::~bncApp() {
     44  delete _logStream;
     45  delete _logFile;
    3546}
    3647
     
    3849////////////////////////////////////////////////////////////////////////////
    3950void bncApp::slotMessage(const QByteArray msg) {
    40 #ifndef WIN32
    41   cerr << msg.data() << endl;
    42 #else
    43   static bool        first = true;
    44   static QFile       logFile("BNC.LOG");
    45   static QTextStream logStream;
    46   if (first) {
    47     first = false;
    48     logFile.open(QIODevice::WriteOnly);
    49     logStream.setDevice(&logFile);
     51  if (_logStream) {
     52    *_logStream << msg.data() << endl;
     53    _logStream->flush();
    5054  }
    51   logStream << msg.data() << endl;
    52   logStream.flush();
    53 #endif
     55  else {
     56    cerr << msg.data() << endl;
     57  }
    5458}
  • trunk/BNC/bncapp.h

    r82 r109  
    44
    55#include <QApplication>
     6#include <QFile>
     7#include <QTextStream>
    68
    79class bncApp : public QApplication {
    810  Q_OBJECT
    9 
    1011  public:
    1112    bncApp(int argc, char* argv[], bool GUIenabled);
    1213    virtual ~bncApp(); 
    13 
    1414  public slots:
    1515    void slotMessage(const QByteArray msg);
    16  
    17   private slots:
     16  private:
     17    QFile*       _logFile;
     18    QTextStream* _logStream;
    1819};
    1920#endif
Note: See TracChangeset for help on using the changeset viewer.