Boost.Redis: include/boost/redis/logger.hpp Source File

Boost.Redis 1.84.0 A redis client library

Loading...
Searching...
No Matches
logger.hpp
1/* Copyright (c) 2018-2024 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
27 class logger {
28public:
32 enum class level
33 {
35 disabled,
36
38 emerg,
39
41 alert,
42
44 crit,
45
47 err,
48
50 warning,
51
53 notice,
54
56 info,
57
59 debug
60 };
61
67 logger(level l = level::debug)
68 : level_{l}
69 {}
70
77 void on_resolve(system::error_code const& ec, asio::ip::tcp::resolver::results_type const& res);
78
85 void on_connect(system::error_code const& ec, asio::ip::tcp::endpoint const& ep);
86
92 void on_ssl_handshake(system::error_code const& ec);
93
100 void on_write(system::error_code const& ec, std::string const& payload);
101
108 void on_read(system::error_code const& ec, std::size_t n);
109
116 void on_hello(system::error_code const& ec, generic_response const& resp);
117
123 void set_prefix(std::string_view prefix)
124 {
125 prefix_ = prefix;
126 }
127
128 void trace(std::string_view message);
129 void trace(std::string_view op, system::error_code const& ec);
130
131private:
132 void write_prefix();
133 level level_;
134 std::string_view prefix_;
135};
136
137} // boost::redis
138
139#endif // BOOST_REDIS_LOGGER_HPP
boost::redis::logger
Logger class.
Definition logger.hpp:27
boost::redis::logger::logger
logger(level l=level::debug)
Constructor.
Definition logger.hpp:67
boost::redis::logger::set_prefix
void set_prefix(std::string_view prefix)
Sets a prefix to every log message.
Definition logger.hpp:123
boost::redis::logger::level
level
Syslog-like log levels.
Definition logger.hpp:33
boost::redis::logger::on_resolve
void on_resolve(system::error_code const &ec, asio::ip::tcp::resolver::results_type const &res)
Called when the resolve operation completes.
boost::redis::logger::on_ssl_handshake
void on_ssl_handshake(system::error_code const &ec)
Called when the ssl handshake operation completes.
boost::redis::logger::on_connect
void on_connect(system::error_code const &ec, asio::ip::tcp::endpoint const &ep)
Called when the connect operation completes.
boost::redis::generic_response
adapter::result< std::vector< resp3::node > > generic_response
A generic response to a request.
Definition response.hpp:35
boost::redis::logger::on_write
void on_write(system::error_code const &ec, std::string const &payload)
Called when the write operation completes.
boost::redis::logger::on_hello
void on_hello(system::error_code const &ec, generic_response const &resp)
Called when the HELLO request completes.
boost::redis::logger::on_read
void on_read(system::error_code const &ec, std::size_t n)
Called when the read operation completes.
boost::redis::logger::level::disabled
@ disabled
Disabled.
boost::redis::logger::level::err
@ err
Error.
boost::redis::logger::level::crit
@ crit
Critical.
boost::redis::logger::level::warning
@ warning
Warning.
boost::redis::logger::level::alert
@ alert
Alert.
boost::redis::logger::level::debug
@ debug
Debug.
boost::redis::logger::level::info
@ info
Info.
boost::redis::logger::level::emerg
@ emerg
Emergency.
boost::redis::logger::level::notice
@ notice
Notice.