#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, time_t 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) |
void | decode (void) |
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 |
void | length (long) |
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 . | |
int | msg_data (const ACE_TCHAR *data) |
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. | |
ACE_Log_Record (const ACE_Log_Record &rhs) | |
disallow copying... | |
ACE_Log_Record & | operator= (const ACE_Log_Record &rhs) |
Private Attributes | |
ACE_INT32 | length_ |
ACE_UINT32 | type_ |
Type of logging record. | |
time_t | 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. | |
size_t | msg_data_size_ |
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 196 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, MAXLOGMSGLEN, msg_data_, and msg_data_size_.
00197 : length_ (0), 00198 type_ (0), 00199 secs_ (0), 00200 usecs_ (0), 00201 pid_ (0), 00202 msg_data_ (0), 00203 msg_data_size_ (0) 00204 { 00205 // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); 00206 ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); 00207 if (0 != this->msg_data_) 00208 { 00209 this->msg_data_size_ = MAXLOGMSGLEN; 00210 this->msg_data_[0] = '\0'; 00211 } 00212 } |
|
Definition at line 143 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, MAXLOGMSGLEN, msg_data_, and msg_data_size_.
00146 : length_ (0), 00147 type_ (ACE_UINT32 (lp)), 00148 secs_ (ts_sec), 00149 usecs_ (0), 00150 pid_ (ACE_UINT32 (p)), 00151 msg_data_ (0), 00152 msg_data_size_ (0) 00153 { 00154 // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); 00155 ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); 00156 if (0 != this->msg_data_) 00157 { 00158 this->msg_data_size_ = MAXLOGMSGLEN; 00159 this->msg_data_[0] = '\0'; 00160 } 00161 } |
|
Definition at line 163 of file Log_Record.cpp. References ACE_NEW_NORETURN, ACE_TCHAR, MAXLOGMSGLEN, msg_data_, and msg_data_size_.
00166 : length_ (0), 00167 type_ (ACE_UINT32 (lp)), 00168 secs_ (ts.sec ()), 00169 usecs_ ((ACE_UINT32) ts.usec ()), 00170 pid_ (ACE_UINT32 (p)), 00171 msg_data_ (0), 00172 msg_data_size_ (0) 00173 { 00174 // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); 00175 ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); 00176 if (0 != this->msg_data_) 00177 { 00178 this->msg_data_size_ = MAXLOGMSGLEN; 00179 this->msg_data_[0] = '\0'; 00180 } 00181 } |
|
Default dtor.
Definition at line 13 of file Log_Record.inl. References msg_data_.
|
|
disallow copying...
|
|
Decode the received from the network.
Definition at line 37 of file Log_Record.inl. References ACE_TRACE, ACE_Time_Value::sec(), secs_, ACE_Time_Value::usec(), and usecs_.
00038 { 00039 ACE_TRACE ("ACE_Log_Record::decode"); 00040 #if !defined (ACE_LACKS_NTOHL) 00041 ACE_Time_Value tv (this->secs_, 00042 ntohl (this->usecs_)); 00043 00044 this->secs_ = tv.sec (); 00045 this->usecs_ = tv.usec (); 00046 this->type_ = ntohl (this->type_); 00047 this->pid_ = ntohl (this->pid_); 00048 this->length_ = ntohl (this->length_); 00049 #endif /* ACE_LACKS_NTOHL */ 00050 } |
|
Dump the state of an object.
Definition at line 106 of file Log_Record.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, and LM_DEBUG.
00107 { 00108 #if defined (ACE_HAS_DUMP) 00109 // ACE_TRACE ("ACE_Log_Record::dump"); 00110 00111 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00112 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("length_ = %d\n"), this->length_)); 00113 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntype_ = %u\n"), this->type_)); 00114 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntime_stamp_ = (%:, %d)\n"), 00115 this->secs_, this->usecs_)); 00116 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %u\n"), this->pid_)); 00117 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_data_ (0x%@) = %s\n"), 00118 this->msg_data_, this->msg_data_)); 00119 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_data_size_ = %B\n"), 00120 this->msg_data_size_)); 00121 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00122 #endif /* ACE_HAS_DUMP */ 00123 } |
|
Encode the for transmission on the network.
Definition at line 20 of file Log_Record.inl. References ACE_TRACE, and usecs_.
00021 { 00022 ACE_TRACE ("ACE_Log_Record::encode"); 00023 #if !defined (ACE_LACKS_HTONL) 00024 this->length_ = htonl (this->length_); 00025 this->type_ = htonl (this->type_); 00026 // Make sure we don't enclose the sec() and usec() fields until 00027 // they've been normalized. 00028 // secs_ is commented out because it can be 64 bits. This method is 00029 // deprecated; use the CDR operations instead. 00030 // this->secs_ = htonl (this->secs_); 00031 this->usecs_ = htonl (this->usecs_); 00032 this->pid_ = htonl (this->pid_); 00033 #endif /* ACE_LACKS_HTONL */ 00034 } |
|
Definition at line 215 of file Log_Record.cpp. References ACE_BIT_ENABLED, ACE_Log_Priority, ACE_TCHAR, ACE_TEXT, ACE_OS::ctime_r(), priority_name(), secs_, ACE_OS::sprintf(), and ACE_OS::strcpy(). Referenced by print().
00218 { 00219 /* 0123456789012345678901234 */ 00220 /* Oct 18 14:25:36.000 1989<nul> */ 00221 ACE_TCHAR timestamp[26]; // Only used by VERBOSE and VERBOSE_LITE. 00222 00223 // The sprintf format needs to be different for Windows and POSIX 00224 // in the wide-char case. 00225 #if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) 00226 const ACE_TCHAR *time_fmt = ACE_TEXT ("%s.%03ld %s"); 00227 const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%s@%s@%u@%s@%s"); 00228 const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%s@%s@%s"); 00229 #else 00230 const ACE_TCHAR *time_fmt = ACE_TEXT ("%ls.%03ld %ls"); 00231 const ACE_TCHAR *verbose_fmt = ACE_TEXT ("%ls@%ls@%u@%ls@%ls"); 00232 const ACE_TCHAR *verbose_lite_fmt = ACE_TEXT ("%ls@%ls@%ls"); 00233 #endif 00234 00235 if (ACE_BIT_ENABLED (verbose_flag, 00236 ACE_Log_Msg::VERBOSE) 00237 || ACE_BIT_ENABLED (verbose_flag, 00238 ACE_Log_Msg::VERBOSE_LITE)) 00239 { 00240 time_t const now = this->secs_; 00241 ACE_TCHAR ctp[26]; // 26 is a magic number... 00242 00243 if (ACE_OS::ctime_r (&now, ctp, sizeof ctp) == 0) 00244 return -1; 00245 00246 /* 01234567890123456789012345 */ 00247 /* Wed Oct 18 14:25:36 1989n0 */ 00248 00249 ctp[19] = '\0'; // NUL-terminate after the time. 00250 ctp[24] = '\0'; // NUL-terminate after the date. 00251 00252 ACE_OS::sprintf (timestamp, 00253 time_fmt, 00254 ctp + 4, 00255 ((long) this->usecs_) / 1000, 00256 ctp + 20); 00257 } 00258 00259 if (ACE_BIT_ENABLED (verbose_flag, 00260 ACE_Log_Msg::VERBOSE)) 00261 { 00262 const ACE_TCHAR *lhost_name = ((host_name == 0) 00263 ? ACE_TEXT ("<local_host>") 00264 : host_name); 00265 ACE_OS::sprintf (verbose_msg, 00266 verbose_fmt, 00267 timestamp, 00268 lhost_name, 00269 this->pid_, 00270 ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), 00271 this->msg_data_); 00272 } 00273 else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE)) 00274 ACE_OS::sprintf (verbose_msg, 00275 verbose_lite_fmt, 00276 timestamp, 00277 ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), 00278 this->msg_data_); 00279 else 00280 ACE_OS::strcpy (verbose_msg, this->msg_data_); 00281 return 0; 00282 } |
|
Set the total length of the , which needs to account for the size of the various data member fields. Definition at line 74 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the total length of the , which includes the size of the various data member fields. Definition at line 67 of file Log_Record.inl. References ACE_TRACE.
|
|
Set the message data of the record. If data is longer than the current msg_data_ buffer, a new msg_data_ buffer is allocated to fit. If such a reallocation faisl, this method returns -1, else 0. Definition at line 126 of file Log_Record.cpp. References ACE_NEW_RETURN, ACE_TCHAR, msg_data_, msg_data_size_, round_up(), ACE_OS::strcpy(), and ACE_OS::strlen().
00127 { 00128 // ACE_TRACE ("ACE_Log_Record::msg_data"); 00129 size_t const newlen = ACE_OS::strlen (data) + 1; // Will need room for '\0' 00130 if (newlen > this->msg_data_size_) 00131 { 00132 ACE_TCHAR *new_msg_data = 0; 00133 ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1); 00134 delete [] this->msg_data_; 00135 this->msg_data_ = new_msg_data; 00136 this->msg_data_size_ = newlen; 00137 } 00138 ACE_OS::strcpy (this->msg_data_, data); 00139 this->round_up (); 00140 return 0; 00141 } |
|
Get the message data of the .
Definition at line 110 of file Log_Record.inl. References ACE_TRACE, and msg_data_. Referenced by ACE_Log_Msg_UNIX_Syslog::log(), ACE_Log_Msg::log(), operator<<(), 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 ACE_Log_Msg_IPC::log(), and 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 103 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the process id of the .
Definition at line 96 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 385 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.
00388 { 00389 if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_))) 00390 { 00391 ACE_TCHAR* verbose_msg = 0; 00392 ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); 00393 00394 int const result = this->format_msg (host_name, verbose_flag, verbose_msg); 00395 00396 if (result == 0) 00397 { 00398 // Since ostream expects only chars, we cannot pass wchar_t's 00399 s << ACE_TEXT_ALWAYS_CHAR (verbose_msg); 00400 s.flush (); 00401 } 00402 00403 delete [] verbose_msg; 00404 00405 return result; 00406 } 00407 return 0; 00408 } |
|
Write the contents of the logging record to the appropriate iff the corresponding type is enabled. Definition at line 285 of file Log_Record.cpp. References ACE_LOG_MSG, ACE_Log_Priority, ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT, ACE_OS::fflush(), format_msg(), ACE_OS::fprintf(), MAXVERBOSELOGMSGLEN, and ACE_OS::strlen(). Referenced by ACE_Log_Msg::log().
00288 { 00289 if (ACE_LOG_MSG->log_priority_enabled (ACE_Log_Priority (this->type_))) 00290 { 00291 ACE_TCHAR *verbose_msg = 0; 00292 ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1); 00293 00294 int result = this->format_msg (host_name, verbose_flag, verbose_msg); 00295 00296 if (result == 0) 00297 { 00298 if (fp != 0) 00299 { 00300 int const verbose_msg_len = 00301 static_cast<int> (ACE_OS::strlen (verbose_msg)); 00302 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 00303 int const fwrite_result = ACE_OS::fprintf (fp, 00304 ACE_TEXT ("%ls"), 00305 verbose_msg); 00306 #else 00307 int const fwrite_result = ACE_OS::fprintf (fp, 00308 ACE_TEXT ("%s"), 00309 verbose_msg); 00310 #endif 00311 // We should have written everything 00312 if (fwrite_result != verbose_msg_len) 00313 result = -1; 00314 else 00315 ACE_OS::fflush (fp); 00316 } 00317 } 00318 00319 delete [] verbose_msg; 00320 00321 return result; 00322 } 00323 else 00324 return 0; 00325 } |
|
Set the priority of the (which must be a power of 2, as defined by the enums in ). Definition at line 96 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 85 of file Log_Record.cpp. References ACE_TRACE, and ACE::log2().
00086 { 00087 ACE_TRACE ("ACE_Log_Record::priority"); 00088 00089 // Get the priority of the <Log_Record> <type_>. This is computed 00090 // as the base 2 logarithm of <type_> (which must be a power of 2, 00091 // as defined by the enums in <ACE_Log_Priority>). 00092 return ACE::log2 ((u_long) this->type_); 00093 } |
|
Definition at line 77 of file Log_Record.cpp. References ACE_TCHAR, and ACE::log2().
00079 { 00080 // Name must be a statically allocated string 00081 ace_priority_names[ACE::log2 (p)] = name; 00082 } |
|
Returns a character array with the string form of the parameter. This is used for the verbose printing format. Definition at line 71 of file Log_Record.cpp. References ACE::log2(). Referenced by format_msg(), ACE_Log_Msg_UNIX_Syslog::log(), and ACE_Log_Msg::log().
00072 { 00073 return ace_priority_names[ACE::log2 (p)]; 00074 } |
|
Round up to the alignment restrictions.
Definition at line 184 of file Log_Record.cpp. References ACE_TCHAR, ALIGN_WORDB, and ACE_OS::strlen(). Referenced by msg_data().
00185 { 00186 // ACE_TRACE ("ACE_Log_Record::round_up"); 00187 // Determine the length of the payload. 00188 size_t len = sizeof (*this) + (sizeof (ACE_TCHAR) * ((ACE_OS::strlen (this->msg_data_) + 1))); 00189 00190 // Round up to the alignment. 00191 len = ((len + ACE_Log_Record::ALIGN_WORDB - 1) 00192 & ~(ACE_Log_Record::ALIGN_WORDB - 1)); 00193 this->length_ = static_cast<ACE_UINT32> (len); 00194 } |
|
Set the time stamp of the .
Definition at line 88 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 81 of file Log_Record.inl. References ACE_Time_Value, and ACE_TRACE. Referenced by operator<<(), and operator>>().
00082 { 00083 ACE_TRACE ("ACE_Log_Record::time_stamp"); 00084 return ACE_Time_Value (this->secs_, (long) this->usecs_); 00085 } |
|
Set the type of the .
Definition at line 60 of file Log_Record.inl. References ACE_TRACE.
|
|
Get the type of the .
Definition at line 53 of file Log_Record.inl. References ACE_TRACE. Referenced by ACE_Log_Msg_UNIX_Syslog::log(), operator<<(), and operator>>().
|
|
Declare the dynamic allocation hooks.
Definition at line 175 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 187 of file Log_Record.h. |
|
Logging record data.
Definition at line 200 of file Log_Record.h. Referenced by ACE_Log_Record(), msg_data(), and ~ACE_Log_Record(). |
|
Definition at line 201 of file Log_Record.h. Referenced by ACE_Log_Record(), and msg_data(). |
|
Id of process that generated the logging record.
Definition at line 197 of file Log_Record.h. |
|
Time that the logging record was generated.
Definition at line 193 of file Log_Record.h. Referenced by decode(), format_msg(), and time_stamp(). |
|
Type of logging record.
Definition at line 190 of file Log_Record.h. |
|
Definition at line 194 of file Log_Record.h. Referenced by decode(), encode(), and time_stamp(). |