Loading...
Searching...
No Matches
logger.hpp
/* Copyright (c) 2018-2023 Marcelo Zimbres Silva (mzimbres@gmail.com)
*
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE.txt)
*/
#ifndef BOOST_REDIS_LOGGER_HPP
#define BOOST_REDIS_LOGGER_HPP
#include <boost/redis/response.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <string>
namespace boost::system {class error_code;}
namespace boost::redis {
class logger {
public:
enum class level
{
disabled,
emerg,
alert,
crit,
err,
warning,
notice,
info,
debug
};
logger(level l = level::disabled)
: level_{l}
{}
void on_resolve(system::error_code const& ec, asio::ip::tcp::resolver::results_type const& res);
void on_connect(system::error_code const& ec, asio::ip::tcp::endpoint const& ep);
void on_ssl_handshake(system::error_code const& ec);
void on_connection_lost(system::error_code const& ec);
void on_write(system::error_code const& ec, std::string const& payload);
void on_read(system::error_code const& ec, std::size_t n);
void on_run(system::error_code const& reader_ec, system::error_code const& writer_ec);
void on_hello(system::error_code const& ec, generic_response const& resp);
void set_prefix(std::string_view prefix)
{
prefix_ = prefix;
}
void
on_runner(
system::error_code const& run_all_ec,
system::error_code const& health_check_ec,
system::error_code const& hello_ec);
void
on_check_health(
system::error_code const& ping_ec,
system::error_code const& check_timeout_ec);
void trace(std::string_view reason);
private:
void write_prefix();
level level_;
std::string_view prefix_;
};
} // boost::redis
#endif // BOOST_REDIS_LOGGER_HPP
boost::redis::logger
Logger class.
Definition: logger.hpp:27
boost::redis::logger::on_runner
void on_runner(system::error_code const &run_all_ec, system::error_code const &health_check_ec, system::error_code const &hello_ec)
Called when the runner operation completes.
boost::redis::logger::on_run
void on_run(system::error_code const &reader_ec, system::error_code const &writer_ec)
Called when the run operation completes.
boost::redis::logger::set_prefix
void set_prefix(std::string_view prefix)
Sets a prefix to every log message.
Definition: logger.hpp:138
boost::redis::logger::level
level
Syslog-like log levels.
Definition: logger.hpp:33
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_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::logger::on_write
void on_write(system::error_code const &ec, std::string const &payload)
Called when the write operation completes.
boost::redis::logger::logger
logger(level l=level::disabled)
Constructor.
Definition: logger.hpp:67
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::on_connection_lost
void on_connection_lost(system::error_code const &ec)
Called when the connection is lost.
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.