Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::dmlog_appender Class Reference

#include <dmlog_appender.hpp>

Inheritance diagram for fc::dmlog_appender:
Collaboration diagram for fc::dmlog_appender:

Classes

struct  config
 
class  impl
 

Public Member Functions

 dmlog_appender (const variant &args)
 
 dmlog_appender (const std::optional< config > &args)
 
virtual ~dmlog_appender ()
 
virtual void initialize (boost::asio::io_service &io_service) override
 
virtual void log (const log_message &m) override
 
- Public Member Functions inherited from fc::appender

Additional Inherited Members

- Public Types inherited from fc::appender
typedef std::shared_ptr< appenderptr
 

Detailed Description

Specialized appender for deep mind tracer that sends log messages through stdout correctly formatted for latter consumption by deep mind postprocessing tools from dfuse.

Definition at line 12 of file dmlog_appender.hpp.

Constructor & Destructor Documentation

◆ dmlog_appender() [1/2]

fc::dmlog_appender::dmlog_appender ( const variant & args)
explicit

Definition at line 46 of file dmlog_appender.cpp.

47 :dmlog_appender(args.as<std::optional<config>>()){}
dmlog_appender(const variant &args)

◆ dmlog_appender() [2/2]

fc::dmlog_appender::dmlog_appender ( const std::optional< config > & args)
explicit

◆ ~dmlog_appender()

fc::dmlog_appender::~dmlog_appender ( )
virtual

Definition at line 52 of file dmlog_appender.cpp.

52 {
53 if (my->owns_out)
54 {
55 std::fclose(my->out);
56 }
57 }

Member Function Documentation

◆ initialize()

void fc::dmlog_appender::initialize ( boost::asio::io_service & io_service)
overridevirtual

Implements fc::appender.

Definition at line 59 of file dmlog_appender.cpp.

59{}

◆ log()

void fc::dmlog_appender::log ( const log_message & m)
overridevirtual

Implements fc::appender.

Definition at line 61 of file dmlog_appender.cpp.

61 {
62 FILE* out = my->out;
63
64 string message = format_string( "DMLOG " + m.get_format() + "\n", m.get_data() );
65
66 auto remaining_size = message.size();
67 auto message_ptr = message.c_str();
68 while (!my->is_stopped && remaining_size) {
69 auto written = fwrite(message_ptr, sizeof(char), remaining_size, out);
70
71 // EINTR shouldn't happen anymore, but keep this detection, just in case.
72 if(written == 0 && errno != EINTR)
73 {
74 my->is_stopped = true;
75 }
76
77 if(written != remaining_size)
78 {
79 fprintf(stderr, "DMLOG FPRINTF_FAILED failed written=%lu remaining=%lu %d %s\n", written, remaining_size, ferror(out), strerror(errno));
80 clearerr(out);
81 }
82
83 if(my->is_stopped)
84 {
85 fprintf(stderr, "DMLOG FPRINTF_FAILURE_TERMINATED\n");
86 // Depending on the error, we might have already gotten a SIGPIPE
87 // An extra signal is harmless, though. Use a process targeted
88 // signal (not raise) because the SIGTERM may be blocked in this
89 // thread.
90 kill(getpid(), SIGTERM);
91 }
92
93 message_ptr = &message_ptr[written];
94 remaining_size -= written;
95 }
96 }
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
fc::string format_string(const fc::string &, const variant_object &, bool minimize=false)
Definition variant.cpp:773
Here is the call graph for this function:

The documentation for this class was generated from the following files: