#ifndef SERVICES_BASIC_LOGGER_HPP
#define SERVICES_BASIC_LOGGER_HPP
#include <boost/asio.hpp>
#include <string>
namespace services {
template <typename Service>
class basic_logger
{
public:
typedef Service service_type;
typedef typename service_type::impl_type impl_type;
explicit basic_logger(boost::asio::execution_context& context,
const std::string& identifier)
: service_(boost::asio::use_service<Service>(context)),
impl_(service_.null())
{
service_.create(impl_, identifier);
}
basic_logger(const basic_logger&) = delete;
basic_logger& operator=(basic_logger&) = delete;
~basic_logger()
{
service_.destroy(impl_);
}
void use_file(const std::string& file)
{
service_.use_file(impl_, file);
}
void log(const std::string& message)
{
service_.log(impl_, message);
}
private:
service_type& service_;
impl_type impl_;
};
}
#endif