00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Utils_Logger_LogFormat_
00027 #define HH_SENF_Utils_Logger_LogFormat_ 1
00028
00029
00030 #include <sstream>
00031 #include "TimeSource.hh"
00032 #include <senf/Utils/Console/LazyDirectory.hh>
00033
00034
00035
00036
00037 namespace senf {
00038 namespace log {
00039 namespace detail {
00040
00041 class LogFormat
00042 {
00043 public:
00044 LogFormat();
00045 explicit LogFormat(console::ScopedDirectory<> & dir);
00046
00047 void showTime(bool flag = true);
00048 void showStream(bool flag = true);
00049 void showLevel(bool flag = true);
00050 void showArea(bool flag = true);
00051
00052 void timeFormat(std::string const & format);
00054
00066 void tag(std::string const & tag);
00067
00068 protected:
00069 std::string prefix(time_type timestamp, std::string const & stream,
00070 std::string const & area, unsigned level);
00071 bool isPlainFormat() const;
00072 void consoleFormat(std::ostream & os);
00073
00074 private:
00075
00076 std::string tag_;
00077 std::string timeFormat_;
00078 std::stringstream datestream_;
00079 bool noformat_;
00080 bool showTime_;
00081 bool showStream_;
00082 bool showLevel_;
00083 bool showArea_;
00084 time_type timeBase_;
00085 };
00086
00087 void quoteNonPrintable(std::string & s);
00088 std::string getDefaultTag();
00089
00090 }}}
00091
00092
00093 #include "LogFormat.cci"
00094
00095
00096 #endif
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107