BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
console_appender.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <fc/log/appender.hpp>
3 #include <fc/log/logger.hpp>
4 #include <vector>
5 
6 namespace fc
7 {
8  class console_appender : public appender
9  {
10  public:
11  struct color
12  {
13  enum type {
14  red,
22  };
23  };
24 
25  struct stream { enum type { std_out, std_error }; };
26 
27  struct level_color
28  {
31  :level(l),color(c){}
32 
35  };
36 
37  struct config
38  {
40  :format( "${timestamp} ${thread_name} ${context} ${file}:${line} ${method} ${level}] ${message}" ),
41  stream(console_appender::stream::std_error),max_object_depth(FC_MAX_LOG_OBJECT_DEPTH),flush(true){}
42 
43  std::string format;
45  std::vector<level_color> level_colors;
46  uint32_t max_object_depth;
47  bool flush;
48  };
49 
50 
51  console_appender( const variant& args );
52  console_appender( const config& cfg );
54 
56  virtual void log( const log_message& m );
57 
58  void print( const std::string& text_to_print,
59  color::type text_color = color::console_default );
60 
61  void configure( const config& cfg );
62 
63  private:
64  class impl;
65  std::unique_ptr<impl> my;
66  };
67 } // namespace fc
68 
69 #include <fc/reflect/reflect.hpp>
73 FC_REFLECT( fc::console_appender::config, (format)(stream)(level_colors)(max_object_depth)(flush) )
console_appender::color::type color
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Defines types and macros used to provide reflection.
std::vector< level_color > level_colors
void configure(const config &cfg)
console_appender::stream::type stream
virtual void log(const log_message &m)
level_color(log_level l=log_level::all, color::type c=color::console_default)
#define FC_MAX_LOG_OBJECT_DEPTH
Definition: config.hpp:8
FC_REFLECT_ENUM(graphene::net::core_message_type_enum,(trx_message_type)(block_message_type)(core_message_type_first)(item_ids_inventory_message_type)(blockchain_item_ids_inventory_message_type)(fetch_blockchain_item_ids_message_type)(fetch_items_message_type)(item_not_available_message_type)(hello_message_type)(connection_accepted_message_type)(connection_rejected_message_type)(address_request_message_type)(address_message_type)(closing_connection_message_type)(current_time_request_message_type)(current_time_reply_message_type)(check_firewall_message_type)(check_firewall_reply_message_type)(get_current_connections_request_message_type)(get_current_connections_reply_message_type)(core_message_type_last))(different_chain)(already_connected)(connected_to_self)(not_accepting_connections)(blocked)(invalid_hello_message)(client_too_old))(inbound)(outbound))(firewalled)(not_firewalled))(unable_to_connect)(connection_successful)) namespace std
void print(const std::string &text_to_print, color::type text_color=color::console_default)
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object&#39;s.
Definition: variant.hpp:198
aggregates a message along with the context and associated meta-information.
Definition: api.hpp:15