10#include <boost/asio/io_context.hpp>
11#include <boost/thread/mutex.hpp>
25 dmlog_appender::dmlog_appender(
const std::optional<dmlog_appender::config>& args )
27 if (!args || args->file ==
"-")
33 my->out = std::fopen(args->file.c_str(),
"a");
36 std::setbuf(my->out, nullptr);
41 FC_THROW(
"Failed to open deep mind log file ${name}", (
"name", args->file));
46 dmlog_appender::dmlog_appender(
const variant& args )
49 dmlog_appender::dmlog_appender()
66 auto remaining_size = message.size();
68 while (!my->is_stopped && remaining_size) {
69 auto written = fwrite(
message_ptr,
sizeof(
char), remaining_size, out);
72 if(written == 0 && errno != EINTR)
74 my->is_stopped =
true;
77 if(written != remaining_size)
79 fprintf(stderr,
"DMLOG FPRINTF_FAILED failed written=%lu remaining=%lu %d %s\n", written, remaining_size, ferror(out), strerror(errno));
85 fprintf(stderr,
"DMLOG FPRINTF_FAILURE_TERMINATED\n");
90 kill(getpid(), SIGTERM);
94 remaining_size -= written;
virtual void initialize(boost::asio::io_service &io_service) override
virtual void log(const log_message &m) override
virtual ~dmlog_appender()
aggregates a message along with the context and associated meta-information.
string get_format() const
variant_object get_data() const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
Defines exception's used by fc.
Defines types and helper macros necessary for generating log messages.
fc::string format_string(const fc::string &, const variant_object &, bool minimize=false)