#include <Log_Msg_IPC.h>
Inheritance diagram for ACE_Log_Msg_IPC:
Public Member Functions | |
ACE_Log_Msg_IPC (void) | |
Constructor. | |
virtual | ~ACE_Log_Msg_IPC (void) |
Destructor. | |
virtual int | open (const ACE_TCHAR *logger_key) |
Open a new connection. | |
virtual int | reset (void) |
virtual int | close (void) |
Close the backend completely. | |
virtual int | log (ACE_Log_Record &log_record) |
Private Attributes | |
ACE_LOG_MSG_IPC_STREAM | message_queue_ |
Implement an ACE_Log_Msg_Backend that logs to a remote logging process.
Definition at line 49 of file Log_Msg_IPC.h.
|
Constructor.
Definition at line 11 of file Log_Msg_IPC.cpp.
00012 { 00013 } |
|
Destructor.
Definition at line 15 of file Log_Msg_IPC.cpp. References close().
00016 { 00017 (void) this->close (); 00018 } |
|
Close the backend completely.
Implements ACE_Log_Msg_Backend. Definition at line 41 of file Log_Msg_IPC.cpp. References message_queue_. Referenced by reset(), and ~ACE_Log_Msg_IPC().
00042 { 00043 return this->message_queue_.close (); 00044 } |
|
Backend routine. This is called when we want to log a message. Since this routine is pure virtual, it must be overwritten by the subclass. Implements ACE_Log_Msg_Backend. Definition at line 47 of file Log_Msg_IPC.cpp. References ACE_CDR_BYTE_ORDER, ACE_OutputCDR::begin(), iovec::iov_base, iovec::iov_len, message_queue_, ACE_Message_Block::rd_ptr(), ACE_OutputCDR::total_length(), and ACE_CDR::ULong.
00048 { 00049 // Serialize the log record using a CDR stream, allocate enough 00050 // space for the complete <ACE_Log_Record>. 00051 const size_t max_payload_size = 00052 4 // type() 00053 + 8 // timestamp 00054 + 4 // process id 00055 + 4 // data length 00056 + ACE_Log_Record::MAXLOGMSGLEN // data 00057 + ACE_CDR::MAX_ALIGNMENT; // padding; 00058 00059 // Insert contents of <log_record> into payload stream. 00060 ACE_OutputCDR payload (max_payload_size); 00061 payload << log_record; 00062 00063 // Get the number of bytes used by the CDR stream. 00064 ACE_CDR::ULong length = payload.total_length (); 00065 00066 // Send a header so the receiver can determine the byte order and 00067 // size of the incoming CDR stream. 00068 ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8); 00069 header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); 00070 00071 // Store the size of the payload that follows 00072 header << ACE_CDR::ULong (length); 00073 00074 // Use an iovec to send both buffer and payload simultaneously. 00075 iovec iov[2]; 00076 iov[0].iov_base = header.begin ()->rd_ptr (); 00077 iov[0].iov_len = 8; 00078 iov[1].iov_base = payload.begin ()->rd_ptr (); 00079 iov[1].iov_len = length; 00080 00081 #if defined (ACE_HAS_STREAM_PIPES) 00082 // Use the <putpmsg> API if supported to ensure correct message 00083 // queueing according to priority. 00084 00085 ACE_Str_Buf header_msg (static_cast<void *> (header.begin ()->rd_ptr ()), 00086 static_cast<int> (8)); 00087 00088 ACE_Str_Buf payload_msg (static_cast<void *> (payload.begin ()->rd_ptr ()), 00089 static_cast<int> (length)); 00090 00091 return this->message_queue_.send (&header_msg, 00092 &payload_msg, 00093 static_cast<int> (log_record.priority ()), 00094 MSG_BAND); 00095 #else 00096 // We're running over sockets, so send header and payload 00097 // efficiently using "gather-write". 00098 return this->message_queue_.sendv_n (iov, 2); 00099 #endif /* ACE_HAS_STREAM_PIPES */ 00100 } |
|
Open a new connection.
Implements ACE_Log_Msg_Backend. Definition at line 21 of file Log_Msg_IPC.cpp. References ACE_LOG_MSG_IPC_ADDR, ACE_LOG_MSG_IPC_CONNECTOR, ACE_TCHAR, and ACE_SOCK_Connector::connect().
00022 { 00023 ACE_LOG_MSG_IPC_CONNECTOR con; 00024 return con.connect (this->message_queue_, 00025 ACE_LOG_MSG_IPC_ADDR (logger_key)); 00026 } |
|
Implements ACE_Log_Msg_Backend. Definition at line 29 of file Log_Msg_IPC.cpp. References close(), and message_queue_.
00030 { 00031 if (this->message_queue_.get_handle () != ACE_INVALID_HANDLE) 00032 { 00033 // If we don't do this, handles aren't reused on Win32 and the 00034 // server eventually crashes! 00035 return this->close (); 00036 } 00037 return 0; 00038 } |
|
Definition at line 65 of file Log_Msg_IPC.h. |