SilentEye 0.4.1
|
00001 // This file is part of SilentEye. 00002 // 00003 // SilentEye is free software: you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation, either version 3 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // SilentEye is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with SilentEye. If not, see <http://www.gnu.org/licenses/>. 00015 00016 #ifndef LOGGER_H 00017 #define LOGGER_H 00018 00019 #include <QPointer> 00020 #include <QObject> 00021 #include <QFile> 00022 #include <QString> 00023 00024 namespace SilentEyeFramework { 00025 00027 class Logger : public QObject 00028 { 00029 public: 00030 enum LogLevel{ DEBUG_LEVEL=1, INFO_LEVEL=5, WARNING_LEVEL=10, ERROR_LEVEL=15 }; 00031 00032 private: 00033 static QPointer<QFile> m_file; 00034 static int m_nbInstance; 00035 static QString m_logFileName; 00036 static LogLevel m_level; 00037 QString m_className; 00038 00039 public: 00040 Logger(QObject* parent = 0); 00041 Logger(QString className); 00042 ~Logger(); 00043 00044 QString className() const; 00045 void setClassName(const QString&); 00046 00047 void debug(QString); 00048 void info(QString); 00049 void warning(QString); 00050 void error(QString); 00051 00052 static void setFileName(const QString&); 00053 static void setLevel(Logger::LogLevel=DEBUG_LEVEL); 00054 static void setLevel(const QString&); 00055 00056 private: 00057 void init(); 00058 void write(QString priority, QString text); 00059 }; 00060 00061 } 00062 00063 #endif // LOGGER_H