- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# log.h

    00001 // Copyright (C) 2008,2009,2010 by Philipp Münzel. All rights reserved.
    00002 // Released under the terms of the license described in license.txt
    00003
    00004 #ifndef LOG_H
    00005 #define LOG_H
    00006
    00007 #include "dllexport.h"
    00008
    00009 #include <string>
    00010 #include <ctime>
    00011 #include <sstream>
    00012 #ifdef HAVE_TR1
    00013 #include <tr1/cstdint>
    00014 #else
    00015 #include <stdint.h>
    00016 #endif
    00017
    00018 namespace SCS {
    00019
    00020 class DLL_PUBLIC LogWriter;
    00021
    00022 enum Level {
    00023     L_UNSPEC=-1,
    00024     L_FAIL  = 0,
    00025     L_ERROR = 1,
    00026     L_WARN  = 2,
    00027     L_INFO  = 3
    00028 };
    00029
    00033 struct DLL_PUBLIC LogEntry {
    00034     Level lvl;
    00035     std::string txt;
    00036     time_t time;
    00037 };
    00038
    00039
    00051 class DLL_PUBLIC Log {
    00052 public:
    00056     Log();
    00057
    00061     static Log& Info(Log& log);
    00062
    00066     static Log& Warn(Log& log);
    00067
    00071     static Log& Error(Log& log);
    00072
    00076     static Log& Fail(Log& log);
    00077
    00081     static Log& endl(Log& log);
    00082
    00087     Log& operator<<(int i);
    00088
    00093     Log& operator<<(uint32_t u32);
    00094
    00099     Log& operator<<(float f);
    00100
    00105     Log& operator<<(double d);
    00106
    00111     Log& operator<<(char c);
    00112
    00117     Log& operator<<(const std::string& s);
    00118
    00119     Log& operator<<(Log& (*f)(Log&));
    00120
    00121 private:
    00122     Level m_severity;
    00123     LogWriter& m_writer;
    00124     std::ostringstream m_stream;
    00125 };
    00126 }
    00127
    00128 #endif // LOG_H