00001 #ifndef N2NC_SYSTEMLOGGER_H
00002 #define N2NC_SYSTEMLOGGER_H
00003
00004 #include "nixsys.h"
00005 #include "mutex.h"
00006
00007 #define N2NC_OUT(str) n2nc::system::Logger::out(str)
00008 #define N2NC_PRINT n2nc::system::Logger::print
00009 #define N2NC_PRINT2 n2nc::system::Logger::print
00010 #define LOGME n2nc::system::Logger::get
00011 #define LOGMET n2nc::system::Logger::gett
00012
00013
00014
00015
00016
00017
00018 namespace n2nc {
00019 namespace system {
00020
00028 class Logger{
00029 public:
00030 Logger();
00031 ~Logger();
00032
00033 static int out(std::string &str);
00034 static int out(std::string str);
00035 static int out(char *str);
00036 static void print(char *frm,...);
00037 Logger& operator<<(char *str);
00038 Logger& operator<<(std::string str);
00039 Logger& operator<<(std::string &str);
00040
00042 static std::ostringstream& get();
00044 static std::ostringstream& gett();
00045 static std::ostringstream& flush();
00046
00048
00049
00050
00052 static std::ostream& dlog();
00054 static std::ostream& dlog(std::ostream &os);
00055
00057 typedef class endl_flush_t{};
00059 typedef class flush_t{};
00060
00061 static flush_t fl ;
00062 static endl_flush_t fendl ;
00063
00064
00065 private:
00066 static sync::Mutex m_std_lock ;
00067 static sync::Mutex m_err_lock ;
00068
00069 static bool m_isloaded ;
00070 static std::ostringstream m_os;
00071 static std::ostringstream m_cout;
00072 static std::string m_logfile ;
00073 static Logger* m_glb_logger ;
00074
00075
00076 friend void operator<<(std::ostream&,Logger::endl_flush_t);
00077 friend void operator<<(std::ostream&,Logger::flush_t);
00078
00079 };
00080
00081
00082
00083
00084
00085 }
00086 }
00087
00088 #endif