11#ifndef __FDP_LOGGING_HXX__
12#define __FDP_LOGGING_HXX__
19namespace FairDataPipeline {
33 const std::string& to_string(
enum LOG_LEVEL lvl );
37 typedef std::shared_ptr< ISink > sptr;
38 virtual int log(
enum LOG_LEVEL msg_lvl,
const std::string& msg ) = 0;
45 typedef std::shared_ptr< SinkFormatter > SinkFormatterPtr;
49 typedef std::shared_ptr< ISinkFormatter > sptr;
50 virtual std::string header(
enum LOG_LEVEL msg_lvl,
Logger*
logger )= 0;
58 typedef std::shared_ptr< Sink > sptr;
61 enum LOG_LEVEL log_level();
62 void log_level(
enum LOG_LEVEL log_lvl );
64 bool should_log(
enum LOG_LEVEL msg_lvl );
66 void set_formatter( ISinkFormatter::sptr fmtr ){_fmtr = fmtr;}
68 int execute(
Logger*
logger,
enum LOG_LEVEL msg_lvl,
const std::string& s );
71 Sink(
enum LOG_LEVEL log_lvl );
76 enum LOG_LEVEL _log_lvl;
77 ISinkFormatter::sptr _fmtr;
84 typedef std::shared_ptr< OStreamSink > sptr;
86 static sptr create(
enum LOG_LEVEL lvl, std::ostream& os );
88 int log(
enum LOG_LEVEL msg_lvl,
const std::string& s);
92 OStreamSink(
enum LOG_LEVEL log_lvl, std::ostream& os);
100 typedef std::shared_ptr< CompositeSink > sptr;
103 static sptr create(
enum LOG_LEVEL lvl ){
return sptr(
new CompositeSink( lvl ) ); }
106 int log(
enum LOG_LEVEL msg_lvl,
const std::string& s);
107 void add_sink( Sink::sptr sink ){ _sinks.push_back( sink ); }
110 std::vector< Sink::sptr > _sinks;
119 typedef std::shared_ptr< SinkFormatter > sptr;
127 std::string header(
enum LOG_LEVEL msg_lvl,
Logger*
logger );
136 typedef std::shared_ptr< Logger > sptr;
141 typedef std::shared_ptr< MsgBuilder > sptr;
145 template<
typename T >
148 if( _logger->sink()->should_log( _msg_lvl ) )
160 enum LOG_LEVEL _msg_lvl;
162 std::ostringstream _oss{
""};
165 static sptr create(
enum LOG_LEVEL lvl, Sink::sptr sink, std::string name=
"" );
174 Sink::sptr sink(){
return _sink; }
175 const std::string& name()
const {
return _name;}
177 void set_level(
enum LOG_LEVEL lvl){ _log_lvl = lvl;}
178 enum LOG_LEVEL get_level()
const {
return _log_lvl;}
181 Logger(
enum LOG_LEVEL lvl, Sink::sptr sink, std::string name ) ;
185 enum LOG_LEVEL _log_lvl;
194 typedef std::shared_ptr< logging::Logger > logger_sptr;
196 static logger_sptr get_logger();
198 static logger_sptr _instance;
Definition: logging.hxx:192
Definition: logging.hxx:98
Definition: logging.hxx:138
Definition: logging.hxx:134
Definition: logging.hxx:82
Definition: logging.hxx:56
Definition: logging.hxx:36