![]() |
IOT
0.5
I Only Think
|
00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 /* IOT Copyright (C) 2010 CEG development team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 00007 * as published by the Free Software Foundation. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Authors: CEG <ceg@ionlythink.com>, http://www.ionlythink.com 00019 */ 00020 #ifndef LOGGER_H 00021 #define LOGGER_H 00022 00023 class QFile; 00024 class QString; 00025 class QTextStream; 00026 class QMutex; 00027 00031 enum loglevel 00032 { 00033 DEBUG_LOG = 0, 00034 INFO_LOG = 1, 00035 WARNING_LOG = 2, 00036 ERROR_LOG = 3, 00037 }; 00038 00043 class Logger 00044 { 00045 public: 00046 static Logger* getInstance(); 00047 static void destroy(); 00048 00049 loglevel getLogLevel() const; 00050 void setLogLevel(loglevel newLogLevel); 00051 QString getLogFile() const; 00052 void setLogFile(QString const & filename); 00053 00054 void log(loglevel msgLogLevel, QString const & msg); 00055 00056 private: 00057 Logger(); 00058 ~Logger(); 00059 00060 private: 00061 loglevel _currentLogLevel; 00062 QFile* _logFile; 00063 static Logger* _instance; 00064 static QMutex _instanceMutex; 00065 }; 00066 00067 #endif // LOGGER_H