TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/common/utils/Formatter.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_COMMON_FORMATTERS_HPP_
00002 #define _TUTTLE_COMMON_FORMATTERS_HPP_
00003 
00004 #include "color.hpp"
00005 
00006 #include <fstream>
00007 #include <iomanip>
00008 
00009 #include <boost/utility.hpp>
00010 #include <boost/shared_ptr.hpp>
00011 #include <boost/make_shared.hpp>
00012 
00013 #ifndef WITHOUT_BOOST_LOG
00014 
00015 #include <boost/log/core.hpp>
00016 #include <boost/log/trivial.hpp>
00017 #include <boost/log/expressions.hpp>
00018 #include <boost/log/sinks/sync_frontend.hpp>
00019 #include <boost/log/sinks/text_ostream_backend.hpp>
00020 #include <boost/log/sources/severity_logger.hpp>
00021 #include <boost/log/sources/record_ostream.hpp>
00022 #include <boost/log/utility/setup/common_attributes.hpp>
00023 #include <boost/utility/empty_deleter.hpp>
00024 #include <boost/log/expressions/formatters/stream.hpp>
00025 #include <boost/log/expressions/attr.hpp>
00026 #include <boost/log/expressions/message.hpp>
00027 
00028 #else
00029 
00030 namespace boost {
00031 namespace log {
00032 namespace trivial {
00033 enum severity_level
00034 {
00035     trace,
00036     debug,
00037     info,
00038     warning,
00039     error,
00040     fatal
00041 };
00042 }}}
00043 
00044 #endif
00045 
00046 namespace tuttle {
00047 namespace common {
00048 
00049 class Formatter : boost::noncopyable
00050 {
00051 #ifndef WITHOUT_BOOST_LOG
00052 #ifndef SWIG
00053         typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_ostream_backend > sink_t;
00054 #endif
00055 #endif
00056 
00057 private:
00058         Formatter();
00059 
00060 public:
00061         static boost::shared_ptr<Formatter> get();
00062         ~Formatter() { }
00063 
00064 private:
00065         void init_logging();
00066 
00067 public:
00068         void setLogLevel( const boost::log::trivial::severity_level level );
00069 
00070         void setLogLevel_int( const int level );
00071         void setLogLevel_string( const std::string& level );
00072 
00073         void displayLogLevel( bool display );
00074 
00075 public:
00076         static boost::shared_ptr< Formatter > _formatter;
00077 #ifndef WITHOUT_BOOST_LOG
00078 #ifndef SWIG
00079         boost::shared_ptr< sink_t > _sink;
00080 #endif
00081 #endif
00082 };
00083 
00084 }
00085 }
00086 
00087 #endif