Main Page | Class Hierarchy | Class List | File List | Class Members

Logging.h

00001 // tacppd logging code
00002 // (c) Copyright in 2000-2005 by tacppd team and contributors
00003 // see http://tacppd.org for more information
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 as published by
00007 //  the Free Software Foundation; either version 2 of the License, or
00008 //  (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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // all comments which start from /** - this is comments for KDoc
00020 //  for classes
00021 //    @short [short description of the class]
00022 //    @author [class author]
00023 //    @version [class version]
00024 //    @see [references to other classes or methods]
00025 //  for methods
00026 //    @see [references]
00027 //    @return [sentence describing the return value]
00028 //    @exception [list the exeptions that could be thrown]
00029 //    @param [name id] [description]    - can be multiple
00030 
00031 #ifndef __LOGGING_H__
00032 #define __LOGGING_H__
00033 
00034 #include "global.h"
00035 
00036 #define MAX_LOG_STR_LEN     900
00037 #define LOG_BUFFER_SIZE     20
00038 
00039 // log critical error messages
00040 #define LOG_ERROR       0
00041 // log NetFlow
00042 #define LOG_NETFLOWLOG  252
00043 // log events
00044 #define LOG_EVENT       253
00045 // log informational
00046 #define LOG_INFORM      254
00047 // log logging information to other file
00048 #define LOG_LOGGING     255
00049 // numbers 1-250 - several parts of debugging with lowest level
00050 
00051 namespace tacpp {
00052 
00058 class LogData {
00061   pthread_mutex_t mutex_;
00064   void lock();
00067   void unlock();
00070   int level;
00073   string str_;
00076   bool is_written_;
00077  public:
00080   LogData(int,string);
00083   int get_level();
00086   string get_string();
00089   ~LogData();
00092   bool isWritten();
00095   void setWritten(bool);
00096 };
00097 
00103 class LogList {
00106   pthread_mutex_t mutex_;
00109   void lock();
00112   void unlock();
00115   int num_;
00118   list<LogData*> logs;
00119  public:
00122   int getNum();
00125   LogList(int);
00128   ~LogList();
00131   void add(int,string);
00134   string del(int);
00137   LogData *getEntry();
00140   int size();
00141 };
00142 
00148 class Logging_end {
00149  public:
00150 };
00151 
00157 class Logging_set {
00158  public:
00161   int level;
00164   Logging_set(int a) {
00165     level = a;
00166   }
00169   void operator =(Logging_set x) {
00170     level = x.level;
00171   }
00172 };
00173 
00179 class Logging {
00182   list<LogList*> tacpp_loglist;
00185   pthread_mutex_t Mutex_;
00188   pthread_mutex_t Mutex2_;
00191   void lock2();
00194   void unlock2();
00195  public:
00198   void lock();
00201   void unlock();
00204   Logging();
00207   ~Logging();
00210   LogList *getl(int);
00213   int add();
00216   void del(int);
00219   void out_msg(int, string);
00222   void out_netflow(string);
00225   void out_logging(string);
00228   void log(int, char *fmt,...);
00231   void clear();
00234   int size();
00237   string sbuf;
00240   int log2_level;
00243   bool present;
00246   Logging_end Logging_end_endlog();
00249   Logging_set Logging_set_setlog(int);
00252   Logging& operator <<(const char*);
00255   Logging& operator <<(const int);
00258   Logging& operator <<(const unsigned int);
00261   Logging& operator <<(const string);
00264   Logging& operator <<(ipaddr);
00267   Logging& operator <<(const float);
00270   Logging& operator <<(const double);
00273   Logging& operator <<(const bool);
00276   Logging& operator <<(Logging_end);
00279   Logging& operator <<(Logging_set);
00280 };
00281 
00282 };
00283 
00284 #endif //__LOGGING_H__

Generated on Thu Jul 21 23:09:45 2005 for tacppd.kdevelop by doxygen 1.3.5