Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

src/core/log.h

00001 //------------------------------------------------------------------------------
00002 // log.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
00022 //------------------------------------------------------------------------------
00023 #ifndef __LOG_H_
00024 #define __LOG_H_
00025 
00026 #define gLog Log::instance
00027 
00028 #include "global.h"
00029 #include <QMutex>
00030 #include <QObject>
00031 
00035 class MAIN_EXPORT Log : public QObject
00036 {
00037         Q_OBJECT;
00038 
00039         public:
00043                 static Log                      instance;
00044 
00045                 Log();
00046 
00047                 bool                            areTimestampsEnabled() const { return timestamps; }
00048 
00049                 const QString&          content() const { return logContent; }
00050 
00056                 void                            logPrintf(const char* str, ...);
00057 
00063                 void                            logUnformattedPrintf(const char* str, ...);
00064 
00065                 bool                            isPrintingToStdout() const { return printToStdout; }
00066 
00067                 void                            setPrintingToStdout(bool b) { printToStdout = b; }
00068                 void                            setTimestampsEnabled(bool b) { timestamps = b; }
00069 
00073                 Log&                            operator<<(const QString& string);
00074 
00075         public slots:
00082                 void    addEntry(const QString& string);
00083 
00089                 void    addUnformattedEntry(const QString& string);
00090 
00094                 void    clearContent() { logContent.clear(); }
00095 
00096         signals:
00102                 void    newEntry(const QString& entry);
00103 
00104         protected:
00108                 QString         logContent;
00109                 QMutex          thisMutex;
00110 
00111                 int                     doLogPrintf(char* output, unsigned outputSize, const char* str, va_list argList);
00112 
00118                 bool            printToStdout;
00119 
00123                 bool            timestamps;
00124 
00125 
00126 };
00127 
00128 #endif
   
Doomseeker © 2009-2024 The Doomseeker Team