#include <Log_Record.h>
Public Types | |
enum | { MAXLOGMSGLEN = ACE_MAXLOGMSGLEN+1, ALIGN_WORDB = 8, VERBOSE_LEN = 128, MAXVERBOSELOGMSGLEN = VERBOSE_LEN + MAXLOGMSGLEN } |
Public Member Functions | |
ACE_Log_Record (void) | |
ACE_Log_Record (ACE_Log_Priority lp, long time_stamp, long pid) | |
ACE_Log_Record (ACE_Log_Priority lp, const ACE_Time_Value &time_stamp, long pid) | |
~ACE_Log_Record (void) | |
Default dtor. | |
int | print (const ACE_TCHAR host_name[], u_long verbose_flag, FILE *fp=stderr) |
int | print (const ACE_TCHAR host_name[], u_long verbose_flag, ACE_OSTREAM_TYPE &stream) |
int | format_msg (const ACE_TCHAR host_name[], u_long verbose_flag, ACE_TCHAR *verbose_msg) |
void | encode (void) |
Encode the for transmission on the network. | |
void | decode (void) |
Decode the received from the network. | |
ACE_UINT32 | type (void) const |
Get the type of the . | |
void | type (ACE_UINT32) |
Set the type of the . | |
u_long | priority (void) const |
void | priority (u_long num) |
long | length (void) const |
Get the length of the . | |
void | length (long) |
Set the length of the . | |
ACE_Time_Value | time_stamp (void) const |
Get the time stamp of the . | |
void | time_stamp (const ACE_Time_Value &ts) |
Set the time stamp of the . | |
long | pid (void) const |
Get the process id of the . | |
void | pid (long) |
Set the process id of the . | |
const ACE_TCHAR * | msg_data (void) const |
Get the message data of the . | |
void | set_msg_data_ptr (ACE_TCHAR *data) |
Set the message data pointer. | |
void | msg_data (const ACE_TCHAR *data) |
Set the message data of the . | |
size_t | msg_data_len (void) const |
void | dump (void) const |
Dump the state of an object. | |
Static Public Member Functions | |
const ACE_TCHAR * | priority_name (ACE_Log_Priority p) |
void | priority_name (ACE_Log_Priority p, const ACE_TCHAR *name) |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Member Functions | |
void | round_up (void) |
Round up to the alignment restrictions. | |
Private Attributes | |
ACE_INT32 | length_ |
ACE_UINT32 | type_ |
Type of logging record. | |
ACE_UINT32 | secs_ |
Time that the logging record was generated. | |
ACE_UINT32 | usecs_ |
ACE_UINT32 | pid_ |
Id of process that generated the logging record. | |
ACE_TCHAR * | msg_data_ |
Logging record data. |
Definition at line 37 of file Log_Record.h.
|
Definition at line 40 of file Log_Record.h.
00041 { 00042 /// Maximum size of a logging message. 00043 MAXLOGMSGLEN = ACE_MAXLOGMSGLEN+1, 00044 00045 /// Most restrictive alignment. 00046 ALIGN_WORDB = 8, 00047 00048 /// Size used by verbose mode. 00049 /// 20 (date) + 15 (host_name) + 10 (pid) + 10 (type) 00050 /// + 4 (@) ... + ? (progname) 00051 VERBOSE_LEN = 128, 00052 00053 /// Maximum size of a logging message with the verbose headers 00054 MAXVERBOSELOGMSGLEN = VERBOSE_LEN + MAXLOGMSGLEN 00055 }; |
|
Create a and set its priority, time stamp, and process id. Definition at line 169 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, and MAXLOGMSGLEN.
|
|
Definition at line 128 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, and MAXLOGMSGLEN.
|
|
Definition at line 142 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, and MAXLOGMSGLEN.
00145 : length_ (0), 00146 type_ (ACE_UINT32 (lp)), 00147 secs_ ((ACE_UINT32) ts.sec ()), 00148 usecs_ ((ACE_UINT32) ts.usec ()), 00149 pid_ (ACE_UINT32 (p)), 00150 msg_data_ (0) 00151 { 00152 // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); 00153 ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); 00154 } |
|
Default dtor.
Definition at line 13 of file Log_Record.inl. References msg_data_.
|
|
Decode the received from the network.
Definition at line 33 of file Log_Record.inl. References ACE_TRACE, ACE_Time_Value::sec(), secs_, ACE_Time_Value::usec(), and usecs_.
00034 { 00035 ACE_TRACE ("ACE_Log_Record::decode"); 00036 ACE_Time_Value tv (ntohl (this->secs_), 00037 ntohl (this->usecs_)); 00038 00039 this->secs_ = tv.sec (); 00040 this->usecs_ = tv.usec (); 00041 this->type_ = ntohl (this->type_); 00042 this->pid_ = ntohl (this->pid_); 00043 this->length_ = ntohl (this->length_); 00044 } |
|
Dump the state of an object.
Definition at line 104 of file Log_Record.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, and LM_DEBUG.
00105 { 00106 #if defined (ACE_HAS_DUMP) 00107 // ACE_TRACE ("ACE_Log_Record::dump"); 00108 00109 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00110 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("length_ = %d\n"), this->length_)); 00111 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntype_ = %u\n"), this->type_)); 00112 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntime_stamp_ = (%d, %d)\n"), this->secs_, this->usecs_)); 00113 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %u\n"), this->pid_)); 00114 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_data_ = %s\n"), this->msg_data_)); 00115 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00116 #endif /* ACE_HAS_DUMP */ 00117 } |
|
Encode the for transmission on the network.
Definition at line 20 of file Log_Record.inl. References ACE_TRACE, secs_, and usecs_.
00021 { 00022 ACE_TRACE ("ACE_Log_Record::encode"); 00023 this->length_ = htonl (this->length_); 00024 this->type_ = htonl (this->type_); 00025 // Make sure we don't enclose the sec() and usec() fields until 00026 // they've been normalized. 00027 this->secs_ = htonl (this->secs_); 00028 this->usecs_ = htonl (this->usecs_); 00029 this->pid_ = htonl (this->pid_); 00030 } |
|
Definition at line 182 of file Log_Record.cpp. References ACE_BIT_ENABLED, ACE_LIB_TEXT, ACE_Log_Priority, ACE_TCHAR, ACE_OS::ctime_r(), priority_name(), secs_, ACE_OS::sprintf(), and ACE_OS::strcpy(). Referenced by print().
00185 { 00186 /* 0123456789012345678901234 */ 00187 /* Oct 18 14:25:36.000 1989<nul> */ 00188 ACE_TCHAR timestamp[26]; // Only used by VERBOSE and VERBOSE_LITE. 00189 00190 // The sprintf format needs to be different for Windows and POSIX 00191 // in the wide-char case. 00192 #if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) 00193 const ACE_TCHAR *time_fmt = ACE_LIB_TEXT ("%s.%03ld %s"); 00194 const ACE_TCHAR *verbose_fmt = ACE_LIB_TEXT ("%s@%s@%u@%s@%s"); 00195 const ACE_TCHAR *verbose_lite_fmt = ACE_LIB_TEXT ("%s@%s@%s"); 00196 #else 00197 const ACE_TCHAR *time_fmt = ACE_LIB_TEXT ("%ls.%03ld %ls"); 00198 const ACE_TCHAR *verbose_fmt = ACE_LIB_TEXT ("%ls@%ls@%u@%ls@%ls"); 00199 const ACE_TCHAR *verbose_lite_fmt = ACE_LIB_TEXT ("%ls@%ls@%ls"); 00200 #endif 00201 00202 if (ACE_BIT_ENABLED (verbose_flag, 00203 ACE_Log_Msg::VERBOSE) 00204 || ACE_BIT_ENABLED (verbose_flag, 00205 ACE_Log_Msg::VERBOSE_LITE)) 00206 { 00207 time_t const now = this->secs_; 00208 ACE_TCHAR ctp[26]; // 26 is a magic number... 00209 00210 if (ACE_OS::ctime_r (&now, ctp, sizeof ctp) == 0) 00211 return -1; 00212 00213 /* 01234567890123456789012345 */ 00214 /* Wed Oct 18 14:25:36 1989n0 */ 00215 00216 ctp[19] = '\0'; // NUL-terminate after the time. 00217 ctp[24] = '\0'; // NUL-terminate after the date. 00218 00219 ACE_OS::sprintf (timestamp, 00220 time_fmt, 00221 ctp + 4, 00222 ((long) this->usecs_) / 1000, 00223 ctp + 20); 00224 } 00225 00226 if (ACE_BIT_ENABLED (verbose_flag, 00227 ACE_Log_Msg::VERBOSE)) 00228 { 00229 const ACE_TCHAR *lhost_name = ((host_name == 0) 00230 ? ACE_LIB_TEXT ("<local_host>") 00231 : host_name); 00232 ACE_OS::sprintf (verbose_msg, 00233 verbose_fmt, 00234 timestamp, 00235 lhost_name, 00236 this->pid_, 00237 ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), 00238 this->msg_data_); 00239 } 00240 else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE)) 00241 ACE_OS::sprintf (verbose_msg, 00242 verbose_lite_fmt, 00243 timestamp, 00244 ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), 00245 this->msg_data_); 00246 else 00247 ACE_OS::strcpy (verbose_msg, this->msg_data_); 00248 return 0; 00249 } |
|
Set the length of the .
Definition at line 68 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the length of the .
Definition at line 61 of file Log_Record.inl. References ACE_TRACE. Referenced by ACE_Log_Msg_NT_Event_Log::log().
|
|
Set the message data of the .
Definition at line 120 of file Log_Record.cpp. References ACE_TCHAR, MAXLOGMSGLEN, round_up(), and ACE_OS::strsncpy().
00121 { 00122 // ACE_TRACE ("ACE_Log_Record::msg_data"); 00123 ACE_OS::strsncpy (this->msg_data_, data, 00124 (MAXLOGMSGLEN / sizeof (ACE_TCHAR))); 00125 this->round_up (); 00126 } |
|
Get the message data of the .
Definition at line 104 of file Log_Record.inl. References ACE_TRACE, and msg_data_. Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Log_Msg_NT_Event_Log::log(), ACE_Log_Msg::log(), and operator<<().
|
|
Get the size of the message data of the , including a byte for the NUL. Definition at line 117 of file Log_Record.inl. References ACE_TRACE, and ACE_OS::strlen(). Referenced by operator<<().
00118 { 00119 ACE_TRACE ("ACE_Log_Record::msg_data_len"); 00120 return ACE_OS::strlen (this->msg_data_) + 1; 00121 } |
|
Set the process id of the .
Definition at line 97 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the process id of the .
Definition at line 90 of file Log_Record.inl. References ACE_TRACE. Referenced by operator<<(), and operator>>().
|
|
Write the contents of the logging record to the appropriate iff the corresponding type is enabled. Definition at line 345 of file Log_Record.cpp. References ACE_LOG_MSG, ACE_Log_Priority, ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT_ALWAYS_CHAR, format_msg(), and MAXVERBOSELOGMSGLEN.
00348 { 00349 if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_))) 00350 { 00351 ACE_TCHAR* verbose_msg = 0; 00352 ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); 00353 00354 int const result = this->format_msg (host_name, verbose_flag, verbose_msg); 00355 00356 if (result == 0) 00357 { 00358 // Since ostream expects only chars, we cannot pass wchar_t's 00359 s << ACE_TEXT_ALWAYS_CHAR (verbose_msg); 00360 s.flush (); 00361 } 00362 00363 delete [] verbose_msg; 00364 00365 return result; 00366 } 00367 return 0; 00368 } |
|
Write the contents of the logging record to the appropriate iff the corresponding type is enabled. Definition at line 252 of file Log_Record.cpp. References ACE_LIB_TEXT, ACE_LOG_MSG, ACE_Log_Priority, ACE_NEW_RETURN, ACE_TCHAR, ACE_OS::fflush(), format_msg(), ACE_OS::fprintf(), MAXVERBOSELOGMSGLEN, and ACE_OS::strlen(). Referenced by ACE_Log_Msg::log().
00255 { 00256 if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_))) 00257 { 00258 ACE_TCHAR *verbose_msg = 0; 00259 ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); 00260 00261 int result = this->format_msg (host_name, 00262 verbose_flag, 00263 verbose_msg); 00264 00265 if (result == 0) 00266 { 00267 if (fp != 0) 00268 { 00269 int verbose_msg_len = 00270 static_cast<int> (ACE_OS::strlen (verbose_msg)); 00271 int fwrite_result = ACE_OS::fprintf (fp, 00272 ACE_LIB_TEXT ("%s"), 00273 verbose_msg); 00274 // We should have written everything 00275 if (fwrite_result != verbose_msg_len) 00276 result = -1; 00277 else 00278 ACE_OS::fflush (fp); 00279 } 00280 } 00281 00282 delete [] verbose_msg; 00283 00284 return result; 00285 } 00286 else 00287 return 0; 00288 } |
|
Set the priority of the (which must be a power of 2, as defined by the enums in ). Definition at line 94 of file Log_Record.cpp. References ACE_TRACE.
|
|
Get the priority of the . This is computed as the base 2 logarithm of (which must be a power of 2, as defined by the enums in ). Definition at line 83 of file Log_Record.cpp. References ACE_TRACE, and ACE::log2().
00084 { 00085 ACE_TRACE ("ACE_Log_Record::priority"); 00086 00087 // Get the priority of the <Log_Record> <type_>. This is computed 00088 // as the base 2 logarithm of <type_> (which must be a power of 2, 00089 // as defined by the enums in <ACE_Log_Priority>). 00090 return ACE::log2 ((u_long) this->type_); 00091 } |
|
Definition at line 75 of file Log_Record.cpp. References ACE_TCHAR, and ACE::log2().
00077 { 00078 // Name must be a statically allocated string 00079 ace_priority_names[ACE::log2 (p)] = name; 00080 } |
|
Returns a character array with the string form of the parameter. This is used for the verbose printing format. Definition at line 69 of file Log_Record.cpp. References ACE::log2(). Referenced by format_msg(), ACE_Log_Msg_UNIX_Syslog::log(), and ACE_Log_Msg::log().
00070 { 00071 return ace_priority_names[ACE::log2 (p)]; 00072 } |
|
Round up to the alignment restrictions.
Definition at line 157 of file Log_Record.cpp. References ACE_TCHAR, ALIGN_WORDB, and ACE_OS::strlen(). Referenced by msg_data().
00158 { 00159 // ACE_TRACE ("ACE_Log_Record::round_up"); 00160 // Determine the length of the payload. 00161 size_t len = sizeof (*this) + (sizeof (ACE_TCHAR) * ((ACE_OS::strlen (this->msg_data_) + 1))); 00162 00163 // Round up to the alignment. 00164 len = ((len + ACE_Log_Record::ALIGN_WORDB - 1) 00165 & ~(ACE_Log_Record::ALIGN_WORDB - 1)); 00166 this->length_ = static_cast<ACE_UINT32> (len); 00167 } |
|
Set the message data pointer.
Definition at line 111 of file Log_Record.inl. References ACE_TCHAR, and msg_data_. Referenced by operator>>().
00112 { 00113 this->msg_data_ = data; 00114 } |
|
Set the time stamp of the .
Definition at line 82 of file Log_Record.inl. References ACE_TRACE, ACE_Time_Value::sec(), secs_, ACE_Time_Value::usec(), and usecs_.
|
|
Get the time stamp of the .
Definition at line 75 of file Log_Record.inl. References ACE_Time_Value, and ACE_TRACE. Referenced by operator<<(), and operator>>().
00076 { 00077 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00078 return ACE_Time_Value ((long) this->secs_, (long) this->usecs_); 00079 } |
|
Set the type of the .
Definition at line 54 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the type of the .
Definition at line 47 of file Log_Record.inl. References ACE_TRACE. Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Log_Msg_NT_Event_Log::log(), operator<<(), and operator>>().
|
|
Declare the dynamic allocation hooks.
Definition at line 168 of file Log_Record.h. |
|
Total length of the logging record in bytes. This field *must* come first in order for various IPC framing mechanisms to work correctly. In addition, the field must be an ACE_INT32 in order to be passed portably across platforms. Definition at line 180 of file Log_Record.h. |
|
Logging record data.
Definition at line 193 of file Log_Record.h. Referenced by msg_data(), set_msg_data_ptr(), and ~ACE_Log_Record(). |
|
Id of process that generated the logging record.
Definition at line 190 of file Log_Record.h. |
|
Time that the logging record was generated.
Definition at line 186 of file Log_Record.h. Referenced by decode(), encode(), format_msg(), and time_stamp(). |
|
Type of logging record.
Definition at line 183 of file Log_Record.h. |
|
Definition at line 187 of file Log_Record.h. Referenced by decode(), encode(), and time_stamp(). |