boost_redis 1.4.2
A redis client library
logger.hpp
1/* Copyright (c) 2018-2022 Marcelo Zimbres Silva (mzimbres@gmail.com)
2 *
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE.txt)
5 */
6
7#ifndef BOOST_REDIS_LOGGER_HPP
8#define BOOST_REDIS_LOGGER_HPP
9
10#include <boost/redis/response.hpp>
11#include <boost/asio/ip/tcp.hpp>
12#include <string>
13
14namespace boost::system {class error_code;}
15
16namespace boost::redis {
17
23class logger {
24public:
28 enum class level
29 {
30 emerg,
31
33 alert,
34
36 crit,
37
39 err,
40
42 warning,
43
45 notice,
46
48 info,
49
51 debug
52 };
53
60 : level_{l}
61 {}
62
69 void on_resolve(system::error_code const& ec, asio::ip::tcp::resolver::results_type const& res);
70
77 void on_connect(system::error_code const& ec, asio::ip::tcp::endpoint const& ep);
78
84 void on_ssl_handshake(system::error_code const& ec);
85
91 void on_connection_lost(system::error_code const& ec);
92
99 void on_write(system::error_code const& ec, std::string const& payload);
100
107 void on_hello(system::error_code const& ec, generic_response const& resp);
108
114 void set_prefix(std::string_view prefix)
115 {
116 prefix_ = prefix;
117 }
118
119private:
120 void write_prefix();
121 level level_;
122 std::string_view prefix_;
123};
124
125} // boost::redis
126
127#endif // BOOST_REDIS_LOGGER_HPP
Logger class.
Definition: logger.hpp:23
logger(level l=level::info)
Constructor.
Definition: logger.hpp:59
void set_prefix(std::string_view prefix)
Sets a prefix to every log message.
Definition: logger.hpp:114
level
Syslog-like log levels.
Definition: logger.hpp:29
adapter::result< std::vector< resp3::node > > generic_response
A generic response to a request.
Definition: response.hpp:33
void on_resolve(system::error_code const &ec, asio::ip::tcp::resolver::results_type const &res)
Called when the resolve operation completes.
void on_ssl_handshake(system::error_code const &ec)
Called when the ssl handshake operation completes.
void on_connect(system::error_code const &ec, asio::ip::tcp::endpoint const &ep)
Called when the connect operation completes.
void on_write(system::error_code const &ec, std::string const &payload)
Called when the write operation completes.
void on_hello(system::error_code const &ec, generic_response const &resp)
Called when the HELLO request completes.
void on_connection_lost(system::error_code const &ec)
Called when the connection is lost.