LogMessage.hpp

Go to the documentation of this file.
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 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00029 //  Wei Yan - Chinese Academy of Sciences . 2011
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    };   // End of class 'LogMessage'
00119    
00120 }   // End of namespace gpstk
00121 
00122 
00123 #endif  //GPSTK_LOGMESSAGE_HPP
00124 

Generated on Tue May 22 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1