BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
appender.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 #include <string>
4 
5 namespace fc {
6  class appender;
7  class log_message;
8  class variant;
9 
11  public:
12  typedef std::shared_ptr<appender_factory> ptr;
13 
14  virtual ~appender_factory(){};
15  virtual std::shared_ptr<appender> create( const variant& args ) = 0;
16  };
17 
18  namespace detail {
19  template<typename T>
21  public:
22  virtual std::shared_ptr<appender> create( const variant& args ) {
23  return std::shared_ptr<appender>(new T(args));
24  }
25  };
26  }
27 
28  class appender {
29  public:
30  typedef std::shared_ptr<appender> ptr;
31 
32  template<typename T>
33  static bool register_appender(const std::string& type) {
34  return register_appender( type, appender_factory::ptr( new detail::appender_factory_impl<T>() ) );
35  }
36 
37  virtual ~appender() = default;
38  static appender::ptr create( const std::string& name, const std::string& type, const variant& args );
39  static appender::ptr get( const std::string& name );
40  static bool register_appender( const std::string& type, const appender_factory::ptr& f );
41 
42  virtual void log( const log_message& m ) = 0;
43  };
44 }
std::shared_ptr< appender > ptr
Definition: appender.hpp:30
virtual std::shared_ptr< appender > create(const variant &args)
Definition: appender.hpp:22
virtual ~appender_factory()
Definition: appender.hpp:14
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object&#39;s.
Definition: variant.hpp:198
static bool register_appender(const std::string &type)
Definition: appender.hpp:33
aggregates a message along with the context and associated meta-information.
Definition: api.hpp:15
virtual std::shared_ptr< appender > create(const variant &args)=0
std::shared_ptr< appender_factory > ptr
Definition: appender.hpp:12