00001 #pragma ident "$Id: LogMessage.hpp 2942 2011-10-25 16:43:21Z yanweignss $"
00002
00008 #ifndef GPSTK_LOGMESSAGE_HPP
00009 #define GPSTK_LOGMESSAGE_HPP
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <string>
00034 #include "DayTime.hpp"
00035 #include "DebugUtils.hpp"
00036
00037 namespace gpstk
00038 {
00039
00040 enum LogLevel
00041 {
00042 LEVEL_FATAL = 1,
00043 LEVEL_CRITICAL,
00044 LEVEL_ERROR,
00045 LEVEL_WARNING,
00046 LEVEL_NOTICE,
00047 LEVEL_INFORMATION,
00048 LEVEL_DEBUG,
00049 LEVEL_TRACE,
00050 MAX_LEVEL
00051 };
00052
00053 static std::string LogLevelName(int level)
00054 {
00055 static const std::string names[] =
00056 {
00057 "",
00058 "Fatal",
00059 "Critical",
00060 "Error",
00061 "Warning",
00062 "Notice",
00063 "Information",
00064 "Debug",
00065 "Trace"
00066 };
00067
00068 GPSTK_ASSERT( (level>=1) && (level<=8) );
00069
00070 return names[level];
00071 }
00072
00073 class LogMessage
00074 {
00075 public:
00076
00077 LogMessage()
00078 : source(""),
00079 text(""),
00080 level(LEVEL_INFORMATION),
00081 file(""),
00082 function(""),
00083 line(0) {}
00084
00085 LogMessage( std::string source,
00086 std::string text,
00087 LogLevel level,
00088 DayTime time = DayTime(),
00089 std::string file = "",
00090 std::string function = "",
00091 int line = 0)
00092 {
00093 this->source = source;
00094 this->text = text;
00095 this->level = level;
00096 this->time = time;
00097 this->file = file;
00098 this->function = function;
00099 this->line = line;
00100 }
00101
00102
00104 virtual ~LogMessage(){}
00105
00106 protected:
00107 std::string source;
00108 std::string text;
00109 LogLevel level;
00110 DayTime time;
00111 std::string file;
00112 std::string function;
00113 int line;
00114
00115 friend class Logger;
00116 friend class LogChannel;
00117
00118 };
00119
00120 }
00121
00122
00123 #endif //GPSTK_LOGMESSAGE_HPP
00124