BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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}" ),
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>
71 FC_REFLECT_ENUM( fc::console_appender::color::type, (red)(green)(brown)(blue)(magenta)(cyan)(white)(console_default) )
73 FC_REFLECT( fc::console_appender::config, (format)(stream)(level_colors)(max_object_depth)(flush) )
appender.hpp
fc::console_appender::color::green
@ green
Definition: console_appender.hpp:15
fc::console_appender::console_appender
console_appender()
Definition: console_appender.cpp:41
fc::log_level::all
@ all
Definition: log_message.hpp:34
fc::console_appender::color::brown
@ brown
Definition: console_appender.hpp:16
fc::console_appender::config::max_object_depth
uint32_t max_object_depth
Definition: console_appender.hpp:46
fc::console_appender::level_color
Definition: console_appender.hpp:27
fc::console_appender::stream::std_out
@ std_out
Definition: console_appender.hpp:25
fc::console_appender::stream::std_error
@ std_error
Definition: console_appender.hpp:25
fc::console_appender::configure
void configure(const config &cfg)
Definition: console_appender.cpp:45
fc::console_appender::config::level_colors
std::vector< level_color > level_colors
Definition: console_appender.hpp:45
fc
Definition: api.hpp:15
fc::console_appender::color::console_default
@ console_default
Definition: console_appender.hpp:21
fc::console_appender::color::magenta
@ magenta
Definition: console_appender.hpp:18
fc::console_appender::log
virtual void log(const log_message &m)
Definition: console_appender.cpp:90
fc::appender
Definition: appender.hpp:28
FC_MAX_LOG_OBJECT_DEPTH
#define FC_MAX_LOG_OBJECT_DEPTH
Definition: config.hpp:8
reflect.hpp
Defines types and macros used to provide reflection.
fc::console_appender::color::white
@ white
Definition: console_appender.hpp:20
fc::console_appender::stream::type
type
Definition: console_appender.hpp:25
fc::console_appender::color::red
@ red
Definition: console_appender.hpp:14
fc::console_appender::config::stream
console_appender::stream::type stream
Definition: console_appender.hpp:44
fc::console_appender::level_color::color
console_appender::color::type color
Definition: console_appender.hpp:34
fc::console_appender::color
Definition: console_appender.hpp:11
fc::console_appender::print
void print(const std::string &text_to_print, color::type text_color=color::console_default)
Definition: console_appender.cpp:128
fc::console_appender::stream
Definition: console_appender.hpp:25
fc::console_appender::color::type
type
Definition: console_appender.hpp:13
fc::log_message
aggregates a message along with the context and associated meta-information.
Definition: log_message.hpp:106
FC_REFLECT_ENUM
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
Definition: core_messages.hpp:404
fc::console_appender::color::blue
@ blue
Definition: console_appender.hpp:17
fc::variant
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition: variant.hpp:198
fc::console_appender::impl
Definition: console_appender.cpp:21
fc::console_appender::config::flush
bool flush
Definition: console_appender.hpp:47
fc::console_appender::color::cyan
@ cyan
Definition: console_appender.hpp:19
fc::console_appender::config::format
std::string format
Definition: console_appender.hpp:43
logger.hpp
fc::console_appender::~console_appender
~console_appender()
Definition: console_appender.cpp:64
fc::console_appender::config::config
config()
Definition: console_appender.hpp:39
fc::console_appender::config
Definition: console_appender.hpp:37
fc::console_appender::level_color::level
log_level level
Definition: console_appender.hpp:33
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
fc::log_level
Definition: log_message.hpp:23
fc::console_appender::level_color::level_color
level_color(log_level l=log_level::all, color::type c=color::console_default)
Definition: console_appender.hpp:29
fc::console_appender
Definition: console_appender.hpp:8