EzLogger

ezlogger_format_policy.hpp

00001 #ifndef EZLOGGER_FORMAT_POLICY_HPP_HEADER_GRD_
00002 #define EZLOGGER_FORMAT_POLICY_HPP_HEADER_GRD_
00003 
00004 #include <string>
00005 #include <stdio.h>
00006 #include <time.h>
00007 
00008 #include "ezlogger_misc.hpp"
00009 
00010 namespace axter
00011 {
00023         class ezlogger_format_policy
00024         {
00025         public:
00026                 inline static std::string get_log_prefix_format(const char*FileName, 
00027                         int LineNo, const char*FunctionName, ext_data levels_format_usage_data)
00028                 {
00029                         std::string FileNameOnly = FileName;
00030                         size_t pos = FileNameOnly.rfind('\\');
00031                         if (pos != std::string::npos)
00032                         {
00033                                 FileNameOnly = FileNameOnly.substr(pos+1);
00034                         }
00035                         char FileNameFormat[999] = {0};
00036                         sprintf(FileNameFormat, "%-32s(%5.5i): , [%-16s], [s_%i] [%s, ", 
00037                                 FileNameOnly.c_str(), LineNo, FunctionName, levels_format_usage_data.m_severity_level, get_current_time_str().c_str());
00038                         return FileNameFormat;
00039                 }
00040         private:
00041                 inline static std::string get_current_time_str()
00042                 {
00043                         time_t t = time(0) ;
00044                         std::string tmp = ctime(&t);
00045                         if (tmp.size()) tmp[tmp.size() -1] = ']';
00046                         return tmp;
00047                 }
00048         };
00049 }
00050 
00051 #endif //EZLOGGER_FORMAT_POLICY_HPP_HEADER_GRD_

Generated on Wed Mar 29 00:31:08 2006 for EzLogger by  doxygen 1.4.6.Axter [Axter-Extended-Version]