#include <RemoteLogger.h>
Inheritance diagram for ASSA::RemoteLogger:
Public Member Functions | |
RemoteLogger () | |
virtual int | open () |
Called by Connector upon establishing connection. | |
virtual int | handle_close (int fd_) |
Called by Reactor when we close connection with log_close(). | |
virtual int | log_open (const char *appname_, const char *logfname_, u_long groups_, u_long maxsize_, Reactor *reactor_) |
Calling results into sending SIGN-ON message. | |
virtual int | log_close (void) |
Close connection to the assa-logd. | |
virtual void | log_resync (void) |
Flush output buffer. | |
virtual int | log_msg (Group g_, size_t indent_level_, const string &func_name_, size_t expected_sz_, const char *fmt_, va_list) |
virtual int | log_func (Group g_, size_t indent_level_, const string &func_name_, marker_t type_) |
Private Types | |
enum | state_t { opened, closed } |
enum | msg_t { SIGN_ON = 0, SIGN_OFF, LOG_MSG } |
Private Member Functions | |
RemoteLogger (const RemoteLogger &) | |
RemoteLogger & | operator= (const RemoteLogger &) |
Private Attributes | |
state_t | m_state |
Reactor * | m_reactor |
bool | m_recursive_call |
If true, recursive call is in progress. |
Definition at line 38 of file RemoteLogger.h.
|
Definition at line 83 of file RemoteLogger.h.
|
|
Definition at line 82 of file RemoteLogger.h.
|
|
Definition at line 30 of file RemoteLogger.cpp. 00030 : 00031 m_state (closed), 00032 m_recursive_call (false) 00033 { 00034 // no-op 00035 }
|
|
|
|
Called by Reactor when we close connection with log_close().
Reimplemented from ASSA::EventHandler. Definition at line 105 of file RemoteLogger.cpp. References closed, ASSA::Logger_Impl::m_logfname, and m_state. 00106 { 00107 m_state = closed; 00108 m_logfname.empty (); 00109 return 0; 00110 }
|
|
Close connection to the assa-logd. Send SIGN_OFF message to the log server and stop data processing. We are managed by Logger class. Implements ASSA::Logger_Impl. Definition at line 89 of file RemoteLogger.cpp. References ASSA::flush(), ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), m_reactor, m_recursive_call, m_state, opened, ASSA::READ_EVENT, ASSA::Reactor::removeHandler(), and SIGN_OFF. 00090 { 00094 if (m_state == opened) { 00095 m_recursive_call = true; 00096 get_stream () << 1234567890 << SIGN_OFF << 0 << ASSA::flush; 00097 m_reactor->removeHandler (this, READ_EVENT); 00098 m_recursive_call = false; 00099 } 00100 return 0; 00101 }
|
|
Header + body (preamble;LOG_MSG;length;msg) Implements ASSA::Logger_Impl. Definition at line 175 of file RemoteLogger.cpp. References ASSA::Logger_Impl::add_timestamp(), closed, ASSA::flush(), ASSA::FUNC_ENTRY, ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), ASSA::Logger_Impl::group_enabled(), ASSA::Logger_Impl::indent_func_name(), LOG_MSG, m_recursive_call, m_state, and ASSA::Socket::xdr_length(). 00179 { 00180 if (m_recursive_call) { 00181 return 0; 00182 } 00183 if (m_state == closed) { 00184 return -1; 00185 } 00186 if (! group_enabled (groups_)) { 00187 return 0; 00188 } 00189 00190 std::ostringstream os; 00191 add_timestamp (os); 00192 indent_func_name (os, func_name_, indent_level_, type_); 00193 os << ((type_ == FUNC_ENTRY) ? "---v---\n" : "---^---\n"); 00194 00197 if (get_stream ().good ()) { 00198 m_recursive_call = true; 00199 get_stream () << 1234567890 << LOG_MSG << Socket::xdr_length (os.str ()) 00200 << os.str () << ASSA::flush; 00201 m_recursive_call = false; 00202 } 00203 else { 00204 m_state = closed; 00205 } 00206 00207 return 0; 00208 }
|
|
Header + body (preamble;LOG_MSG;length;msg) Implements ASSA::Logger_Impl. Definition at line 125 of file RemoteLogger.cpp. References ASSA::Logger_Impl::add_timestamp(), Assure_exit, closed, ASSA::flush(), ASSA::Logger_Impl::format_msg(), ASSA::FUNC_MSG, ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), ASSA::Logger_Impl::group_enabled(), ASSA::Logger_Impl::indent_func_name(), LOG_MSG, m_recursive_call, m_state, and ASSA::Socket::xdr_length(). 00131 { 00132 if (m_recursive_call) { 00133 return 0; 00134 } 00135 if (m_state == closed) { 00136 return -1; 00137 } 00138 if (!group_enabled (groups_)) { 00139 return 0; 00140 } 00141 00142 std::ostringstream os; 00143 add_timestamp (os); 00144 indent_func_name (os, func_name_, indent_level_, FUNC_MSG); 00145 00146 bool release = false; 00147 char* msgbuf_ptr = format_msg (expected_sz_, fmt_, msg_list_, release); 00148 if (msgbuf_ptr == NULL) { 00149 return -1; // failed to format 00150 } 00151 00152 os << msgbuf_ptr; 00153 00154 if (release) { 00155 delete [] msgbuf_ptr; 00156 } 00157 00160 if (get_stream ()) { 00161 m_recursive_call = true; 00162 Assure_exit (os.str ().length () != 0); 00163 get_stream () << 1234567890 << LOG_MSG << Socket::xdr_length (os.str ()) 00164 << os.str () << ASSA::flush; 00165 m_recursive_call = false; 00166 } 00167 else { 00168 m_state = closed; 00169 } 00170 return 0; 00171 }
|
|
Calling results into sending SIGN-ON message. Put stream in a blocking mode. Otherwise, fast clients can override log server. Send SIGN_ON message to the log server. Header + Body Reimplemented from ASSA::Logger_Impl. Definition at line 46 of file RemoteLogger.cpp. References ASSA::flush(), ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), ASSA::Logger_Impl::m_groups, ASSA::Logger_Impl::m_logfname, m_reactor, m_recursive_call, m_state, ASSA::Socket::nonblocking, opened, ASSA::READ_EVENT, ASSA::Reactor::registerIOHandler(), SIGN_ON, ASSA::Socket::turnOptionOff(), and ASSA::Socket::xdr_length(). 00051 { 00052 if (m_recursive_call) { 00053 return 0; 00054 } 00055 m_recursive_call = true; 00056 00057 if (m_state == opened) { 00058 return 0; 00059 } 00060 m_logfname = logfname_; 00061 m_groups = groups_; 00062 m_reactor = reactor_; 00063 00064 m_reactor->registerIOHandler (this, get_stream ().getHandler(), 00065 ASSA::READ_EVENT); 00066 00070 get_stream ().turnOptionOff (Socket::nonblocking); 00071 00074 size_t len = sizeof (maxsize_) + 00075 Socket::xdr_length (appname_) + 00076 Socket::xdr_length (logfname_); 00077 00080 get_stream () << 1234567890 << SIGN_ON << len 00081 << maxsize_ << appname_ << logfname_ << ASSA::flush; 00082 m_state = opened; 00083 m_recursive_call = false; 00084 return 0; 00085 }
|
|
Flush output buffer.
Reimplemented from ASSA::Logger_Impl. Definition at line 114 of file RemoteLogger.cpp. References ASSA::flush(), ASSA::ServiceHandler< ASSA::IPv4Socket >::get_stream(), m_recursive_call, m_state, and opened. 00115 { 00116 if (m_state == opened) { 00117 m_recursive_call = true; 00118 get_stream () << ASSA::flush; 00119 m_recursive_call = false; 00120 } 00121 }
|
|
Called by Connector upon establishing connection.
Implements ASSA::ServiceHandler< ASSA::IPv4Socket >. Definition at line 39 of file RemoteLogger.cpp.
|
|
|
|
Definition at line 86 of file RemoteLogger.h. Referenced by log_close(), and log_open(). |
|
If true, recursive call is in progress.
Definition at line 89 of file RemoteLogger.h. Referenced by log_close(), log_func(), log_msg(), log_open(), and log_resync(). |
|
Definition at line 85 of file RemoteLogger.h. Referenced by handle_close(), log_close(), log_func(), log_msg(), log_open(), and log_resync(). |