Provides a variable length argument message logging abstraction. More...
#include <Log_Msg.h>

Public Types | |
| enum | { STDERR = 1, LOGGER = 2, OSTREAM = 4, MSG_CALLBACK = 8, VERBOSE = 16, VERBOSE_LITE = 32, SILENT = 64, SYSLOG = 128, CUSTOM = 256 } |
| enum | MASK_TYPE { PROCESS = 0, THREAD = 1 } |
Public Member Functions | |
| ACE_Log_Msg (void) | |
| Initialize logger. | |
| ~ACE_Log_Msg (void) | |
| cleanup logger. | |
| int | open (const ACE_TCHAR *prog_name, u_long options_flags=ACE_Log_Msg::STDERR, const ACE_TCHAR *logger_key=0) |
| Initialize the ACE logging facility. | |
| void | set_flags (u_long f) |
| void | clr_flags (u_long f) |
| u_long | flags (void) |
| void | sync (const ACE_TCHAR *program_name) |
| void | op_status (int status) |
| int | op_status (void) const |
| void | errnum (int) |
| int | errnum (void) const |
| void | linenum (int) |
| Set the line number where an error occurred. | |
| int | linenum (void) const |
| Get the line number where an error occurred. | |
| void | file (const char *) |
| Set the file name where an error occurred. | |
| const char * | file (void) |
| Get the file name where an error occurred. | |
| void | msg (const ACE_TCHAR *) |
| Set the message that describes what type of error occurred. | |
| const ACE_TCHAR * | msg (void) |
| Get the message that describes what type of error occurred. | |
| void | restart (bool r) |
| bool | restart (void) const |
| void | msg_ostream (ACE_OSTREAM_TYPE *) |
| Update the ostream without overwriting the delete_ostream_ flag. | |
| void | msg_ostream (ACE_OSTREAM_TYPE *, bool delete_ostream) |
| ACE_OSTREAM_TYPE * | msg_ostream (void) const |
| Get the ostream that is used to print error messages. | |
| ACE_Log_Msg_Callback * | msg_callback (ACE_Log_Msg_Callback *c) |
| ACE_Log_Msg_Callback * | msg_callback (void) const |
| int | inc (void) |
| Nesting depth increment. | |
| int | dec (void) |
| Nesting depth decrement. | |
| int | trace_depth (void) const |
| Get trace depth. | |
| void | trace_depth (int) |
| Set trace depth. | |
| bool | trace_active (void) const |
| Get trace active status. | |
| void | trace_active (bool value) |
| Set trace active status. | |
| ACE_Thread_Descriptor * | thr_desc (void) const |
| Get the TSS thread descriptor. | |
| void | thr_desc (ACE_Thread_Descriptor *td) |
| ACE_SEH_EXCEPT_HANDLER | seh_except_selector (void) |
| ACE_SEH_EXCEPT_HANDLER | seh_except_selector (ACE_SEH_EXCEPT_HANDLER) |
| ACE_SEH_EXCEPT_HANDLER | seh_except_handler (void) |
| ACE_SEH_EXCEPT_HANDLER | seh_except_handler (ACE_SEH_EXCEPT_HANDLER) |
| void | stop_tracing (void) |
| Stop tracing status on a per-thread basis... | |
| void | start_tracing (void) |
| Start tracing status on a per-thread basis... | |
| bool | tracing_enabled (void) const |
| Query tracing status on a per-thread basis... | |
| u_long | priority_mask (MASK_TYPE=THREAD) |
| Get the current ACE_Log_Priority mask. | |
| u_long | priority_mask (u_long, MASK_TYPE=THREAD) |
| Set the ACE_Log_Priority mask, returns original mask. | |
| int | log_priority_enabled (ACE_Log_Priority log_priority) |
| Return true if the requested priority is enabled. | |
| int | log_priority_enabled (ACE_Log_Priority log_priority, const char *,...) |
| Return true if the requested priority is enabled. | |
| int | log_priority_enabled (ACE_Log_Priority log_priority, const wchar_t *,...) |
| Return true if the requested priority is enabled. | |
| pid_t | getpid (void) const |
| const ACE_TCHAR * | local_host (void) const |
| Get the name of the local host. | |
| void | local_host (const ACE_TCHAR *) |
| Set the name of the local host. | |
| void | set (const char *file, int line, int op_status=-1, int errnum=0, bool restart=true, ACE_OSTREAM_TYPE *os=0, ACE_Log_Msg_Callback *c=0) |
| void | conditional_set (const char *file, int line, int op_status, int errnum) |
| ssize_t | log (ACE_Log_Priority priority, const ACE_TCHAR *format,...) |
| ssize_t | log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format,...) |
| ssize_t | log (const ACE_TCHAR *format, ACE_Log_Priority priority, va_list argp) |
| ssize_t | log (ACE_Log_Record &log_record, int suppress_stderr=0) |
| int | log_hexdump (ACE_Log_Priority log_priority, const char *buffer, size_t size, const ACE_TCHAR *text=0) |
| void | dump (void) const |
| Dump the state of an object. | |
Allow apps to acquire and release internal synchronization | |
This lock is used internally by the ACE_Log_Msg implementation. By exporting the lock, applications can hold the lock atomically over a number of calls to ACE_Log_Msg. | |
| int | acquire (void) |
| Acquire the internal lock. | |
| int | release (void) |
| Release the internal lock. | |
Static Public Member Functions | |
| static ACE_Log_Msg * | instance (void) |
| Returns a pointer to the Singleton. | |
| static int | last_error_adapter (void) |
| Returns last error. | |
| static int | exists (void) |
| Returns non-null if an ACE_Log_Msg exists for the calling thread. | |
| static const ACE_TCHAR * | program_name (void) |
| Returns the current program name used for logging. | |
| static void | disable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| static void | enable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| static ACE_Log_Msg_Backend * | msg_backend (ACE_Log_Msg_Backend *b) |
| static ACE_Log_Msg_Backend * | msg_backend (void) |
| static void | init_hook (ACE_OS_Log_Msg_Attributes &attributes#if defined(ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS), ACE_SEH_EXCEPT_HANDLER selector=0, ACE_SEH_EXCEPT_HANDLER handler=0#endif) |
| static void | inherit_hook (ACE_OS_Thread_Descriptor *thr_desc, ACE_OS_Log_Msg_Attributes &attributes) |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
| bool | is_set_ |
| const char * | file_ |
| int | line_ |
| int | op_status_ |
Private Types | |
| typedef ACE_Atomic_Op < ACE_SYNCH_MUTEX, unsigned long > | Atomic_ULong |
Private Member Functions | |
| void | cleanup_ostream () |
| ACE_Log_Msg & | operator= (const ACE_Log_Msg &) |
| ACE_Log_Msg (const ACE_Log_Msg &) | |
Static Private Member Functions | |
| static void | close (void) |
| For cleanup, at program termination. | |
| static void | sync_hook (const ACE_TCHAR *prg_name) |
| Decouple the OS layer from the ACE_Log_Msg layer. | |
| static ACE_OS_Thread_Descriptor * | thr_desc_hook (void) |
| Return the TSS singleton thread descriptor. | |
Private Attributes | |
| int | status_ |
| Status of operation (-1 means failure, >= 0 means success). | |
| int | errnum_ |
| Type of error that occurred (see <sys/errno.h>). | |
| int | linenum_ |
| Line number where the error occurred. | |
| char | file_ [MAXPATHLEN+1] |
| File where the error occurred. | |
| ACE_TCHAR * | msg_ |
| bool | restart_ |
| ACE_OSTREAM_TYPE * | ostream_ |
| The ostream where logging messages can be written. | |
| Atomic_ULong * | ostream_refcount_ |
| ACE_Log_Msg_Callback * | msg_callback_ |
| The callback object. | |
| int | trace_depth_ |
| Depth of the nesting for printing traces. | |
| bool | trace_active_ |
| Are we already within an ACE_Trace constructor call? | |
| bool | tracing_enabled_ |
| Are we allowing tracing in this thread? | |
| ACE_Thread_Descriptor * | thr_desc_ |
| u_long | priority_mask_ |
| int | timestamp_ |
| Always timestamp? | |
| struct { | |
| bool is_set_ | |
| const char * file_ | |
| int line_ | |
| int op_status_ | |
| int errnum_ | |
| } | conditional_values_ |
Static Private Attributes | |
| static u_long | process_priority_mask_ |
| static const ACE_TCHAR * | program_name_ = 0 |
| Records the program name. | |
| static const ACE_TCHAR * | local_host_ = 0 |
| Name of the local host (used when printing messages). | |
| static pid_t | pid_ = -2 |
| Process id of the current process. | |
| static u_long | flags_ = ACE_Log_Msg::STDERR |
| Default is to use stderr. | |
| static ptrdiff_t | msg_off_ = 0 |
| Offset of msg_[]. | |
| static int | instance_count_ = 0 |
| static u_long | default_priority_mask_ = 0 |
| static bool | key_created_ |
Provides a variable length argument message logging abstraction.
This class is very flexible since it allows formatted error messages to be printed in a thread-safe manner to various locations, such as stderr, cerr, a distributed logger, etc. The current message is also kept in a thread-specific storage location (threads spawned using ACE_Thread_Manager automatically get an ACE_Log_Msg object that inherits the spawning thread's settings), which can be used to communicate errors between framework methods and callers. A message is logged by the log() method, only if the message priority is currently enabled. Moreover, only the current log message is stored here -- it will be overwritten by the subsequent call to log().
The ACE_Log_Msg class uses two priority masks to control its logging behavior. The priority_mask_ object attribute is thread- specific and specifies the priority levels logged by the thread. The process_priority_mask_ class attribute is not thread-specific and specifies the priority levels that will be logged by all threads in the process. By default, all levels are disabled for priority_mask_ and all levels are enabled for process_priority_mask_ (i.e. the process-wide mask controls the settings, and each instance can expand on it if desired). Both priority masks can be modified using the priority_mask() method of this class.
Definition at line 178 of file Log_Msg.h.
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, unsigned long> ACE_Log_Msg::Atomic_ULong [private] |
This pointer is 0 if we are not reference counting (the user has not passed "true" for the delete_ostream argument to msg_ostream). If we are reference counting, this points to a shared count that will be deleted when it reaches zero. Since we want optional but shared ownership neither std::auto_ptr nor ACE_Strong_Bound_Ptr have the right semantics. *Bound_Ptr also doesn't take advantage of Atomic_Op.
| anonymous enum |
Definition at line 182 of file Log_Msg.h.
00183 { 00184 /// Write messages to stderr. 00185 STDERR = 1, 00186 /// Write messages to the local client logger deamon. 00187 LOGGER = 2, 00188 /// Write messages to the ostream * stored in thread-specific 00189 /// storage. 00190 OSTREAM = 4, 00191 /// Write messages to the callback object. 00192 MSG_CALLBACK = 8, 00193 /// Display messages in a verbose manner. 00194 VERBOSE = 16, 00195 /// Display messages in a less verbose manner (i.e., only print 00196 /// information that can change between calls). 00197 VERBOSE_LITE = 32, 00198 /// Do not print messages at all (just leave in thread-specific 00199 /// storage for later inspection). 00200 SILENT = 64, 00201 /// Write messages to the system's event log. 00202 SYSLOG = 128, 00203 /// Write messages to the user provided backend 00204 CUSTOM = 256 00205 };
| ACE_Log_Msg::ACE_Log_Msg | ( | void | ) |
Initialize logger.
Definition at line 641 of file Log_Msg.cpp.
00642 : status_ (0), 00643 errnum_ (0), 00644 linenum_ (0), 00645 msg_ (0), 00646 restart_ (1), // Restart by default... 00647 ostream_ (0), 00648 ostream_refcount_ (0), 00649 msg_callback_ (0), 00650 trace_depth_ (0), 00651 trace_active_ (false), 00652 tracing_enabled_ (true), // On by default? 00653 thr_desc_ (0), 00654 priority_mask_ (default_priority_mask_), 00655 timestamp_ (0) 00656 { 00657 // ACE_TRACE ("ACE_Log_Msg::ACE_Log_Msg"); 00658 00659 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00660 *ACE_Log_Msg_Manager::get_lock ())); 00661 ++instance_count_; 00662 00663 if (this->instance_count_ == 1) 00664 ACE_Base_Thread_Adapter::set_log_msg_hooks (ACE_Log_Msg::init_hook, 00665 ACE_Log_Msg::inherit_hook, 00666 ACE_Log_Msg::close, 00667 ACE_Log_Msg::sync_hook, 00668 ACE_Log_Msg::thr_desc_hook); 00669 00670 this->conditional_values_.is_set_ = false; 00671 00672 char *timestamp = ACE_OS::getenv ("ACE_LOG_TIMESTAMP"); 00673 if (timestamp != 0) 00674 { 00675 // If variable is set or is set to date tag so we print date and time. 00676 if (ACE_OS::strcmp (timestamp, "TIME") == 0) 00677 { 00678 this->timestamp_ = 1; 00679 } 00680 else if (ACE_OS::strcmp (timestamp, "DATE") == 0) 00681 { 00682 this->timestamp_ = 2; 00683 } 00684 } 00685 00686 ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]); 00687 }
| ACE_Log_Msg::~ACE_Log_Msg | ( | void | ) |
cleanup logger.
Definition at line 689 of file Log_Msg.cpp.
00690 { 00691 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00692 00693 int instance_count = 0; 00694 00695 // Only hold the guard while updating the instance_count_. 00696 // If ACE_Log_Msg_Manager::close () is called, the lock will 00697 // be deleted. 00698 { 00699 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00700 *ACE_Log_Msg_Manager::get_lock ())); 00701 instance_count = --instance_count_; 00702 } 00703 // Release the guard. 00704 00705 #else /* ! ACE_MT_SAFE */ 00706 int instance_count = --instance_count_; 00707 #endif /* ! ACE_MT_SAFE */ 00708 00709 // If this is the last instance then cleanup. Only the last 00710 // thread to destroy its ACE_Log_Msg instance should execute 00711 // this block. 00712 if (instance_count == 0) 00713 { 00714 // Destroy the message queue instance. 00715 if (ACE_Log_Msg_Manager::log_backend_ != 0) 00716 ACE_Log_Msg_Manager::log_backend_->close (); 00717 00718 // Close down custom backend 00719 if (ACE_Log_Msg_Manager::custom_backend_ != 0) 00720 ACE_Log_Msg_Manager::custom_backend_->close (); 00721 00722 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00723 # if defined (ACE_HAS_TSS_EMULATION) 00724 ACE_Log_Msg_Manager::close (); 00725 # endif /* ACE_HAS_TSS_EMULATION */ 00726 # endif /* ACE_MT_SAFE */ 00727 00728 if (ACE_Log_Msg::program_name_) 00729 { 00730 ACE_OS::free ((void *) ACE_Log_Msg::program_name_); 00731 ACE_Log_Msg::program_name_ = 0; 00732 } 00733 00734 if (ACE_Log_Msg::local_host_) 00735 { 00736 ACE_OS::free ((void *) ACE_Log_Msg::local_host_); 00737 ACE_Log_Msg::local_host_ = 0; 00738 } 00739 } 00740 00741 this->cleanup_ostream (); 00742 00743 delete[] this->msg_; 00744 }
| ACE_Log_Msg::ACE_Log_Msg | ( | const ACE_Log_Msg & | ) | [private] |
| int ACE_Log_Msg::acquire | ( | void | ) |
Acquire the internal lock.
Definition at line 600 of file Log_Msg.cpp.
00601 { 00602 ACE_TRACE ("ACE_Log_Msg::acquire"); 00603 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00604 return ACE_Log_Msg_Manager::get_lock ()->acquire (); 00605 #else /* ! ACE_MT_SAFE */ 00606 return 0; 00607 #endif /* ! ACE_MT_SAFE */ 00608 }
| void ACE_Log_Msg::cleanup_ostream | ( | ) | [private] |
Definition at line 747 of file Log_Msg.cpp.
00748 { 00749 if (this->ostream_refcount_) 00750 { 00751 if (--*this->ostream_refcount_ == 0) 00752 { 00753 delete this->ostream_refcount_; 00754 #if defined (ACE_LACKS_IOSTREAM_TOTALLY) 00755 ACE_OS::fclose (this->ostream_); 00756 #else 00757 delete this->ostream_; 00758 this->ostream_ = 0; 00759 #endif 00760 } 00761 this->ostream_refcount_ = 0; 00762 } 00763 }
| void ACE_Log_Msg::close | ( | void | ) | [static, private] |
For cleanup, at program termination.
Definition at line 473 of file Log_Msg.cpp.
00474 { 00475 // This call needs to go here to avoid memory leaks. 00476 ACE_MT (ACE_Log_Msg_Manager::close ()); 00477 00478 // Please note that this will be called by a statement that is 00479 // harded coded into the ACE_Object_Manager's shutdown sequence, in 00480 // its destructor. 00481 00482 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && \ 00483 (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ 00484 defined (ACE_HAS_TSS_EMULATION)) 00485 00486 if (ACE_Log_Msg::key_created_) 00487 { 00488 ACE_thread_mutex_t *lock = 00489 reinterpret_cast<ACE_thread_mutex_t *> 00490 (ACE_OS_Object_Manager::preallocated_object 00491 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]); 00492 ACE_OS::thread_mutex_lock (lock); 00493 00494 if (ACE_Log_Msg::key_created_) 00495 { 00496 // Clean up this ACE_Log_Msg instance and reset the TSS to 00497 // prevent any future cleanup attempts via TSS mechanisms at 00498 // thread exit. Otherwise in the event of a dynamic library 00499 // unload of libACE, by a program not linked with libACE, 00500 // ACE_TSS_cleanup will be invoked after libACE has been unloaded. 00501 // See Bugzilla 2980 for lots of details. 00502 ACE_Log_Msg *tss_log_msg = 0; 00503 void *temp = 0; 00504 00505 // Get the tss_log_msg from thread-specific storage. 00506 if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) != -1 00507 && temp) 00508 { 00509 tss_log_msg = static_cast <ACE_Log_Msg *> (temp); 00510 // we haven't been cleaned up 00511 ACE_TSS_CLEANUP_NAME(tss_log_msg); 00512 if (ACE_Thread::setspecific(*(log_msg_tss_key()), 00513 reinterpret_cast <void *>(0)) != 0) 00514 ACE_OS::printf ("ACE_Log_Msg::close failed to ACE_Thread::setspecific to 0\n"); 00515 } 00516 00517 // The key is not needed any longer; ACE_Log_Msg is closing 00518 // and will need to be reopened if this process wishes to use 00519 // logging again. So delete the key. 00520 ACE_Thread::keyfree (*(log_msg_tss_key())); 00521 ACE_Log_Msg::key_created_ = false; 00522 } 00523 00524 ACE_OS::thread_mutex_unlock (lock); 00525 } 00526 #endif /* (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) && ACE_MT_SAFE */ 00527 }
| void ACE_Log_Msg::clr_flags | ( | u_long | f | ) |
Disable the bits in the logger's options flags.
Definition at line 590 of file Log_Msg.cpp.
00591 { 00592 ACE_TRACE ("ACE_Log_Msg::clr_flags"); 00593 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00594 *ACE_Log_Msg_Manager::get_lock ())); 00595 00596 ACE_CLR_BITS (ACE_Log_Msg::flags_, flgs); 00597 }
| void ACE_Log_Msg::conditional_set | ( | const char * | file, | |
| int | line, | |||
| int | op_status, | |||
| int | errnum | |||
| ) |
These values are only actually set if the requested priority is enabled.
Definition at line 2389 of file Log_Msg.cpp.
02393 { 02394 this->conditional_values_.is_set_ = true; 02395 this->conditional_values_.file_ = filename; 02396 this->conditional_values_.line_ = line; 02397 this->conditional_values_.op_status_ = status; 02398 this->conditional_values_.errnum_ = err; 02399 }
| int ACE_Log_Msg::dec | ( | void | ) |
Nesting depth decrement.
Definition at line 93 of file Log_Msg.inl.
00094 { 00095 return this->trace_depth_ == 0 ? 0 : --this->trace_depth_; 00096 }
| void ACE_Log_Msg::disable_debug_messages | ( | ACE_Log_Priority | priority = LM_DEBUG |
) | [static] |
Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances.
Definition at line 426 of file Log_Msg.cpp.
00427 { 00428 ACE_CLR_BITS (ACE_Log_Msg::default_priority_mask_, priority); 00429 ACE_Log_Msg *i = ACE_Log_Msg::instance (); 00430 i->priority_mask (i->priority_mask () & ~priority); 00431 }
| void ACE_Log_Msg::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 2402 of file Log_Msg.cpp.
02403 { 02404 #if defined (ACE_HAS_DUMP) 02405 ACE_TRACE ("ACE_Log_Msg::dump"); 02406 02407 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 02408 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("status_ = %d\n"), this->status_)); 02409 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nerrnum_ = %d\n"), this->errnum_)); 02410 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlinenum_ = %d\n"), this->linenum_)); 02411 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nfile_ = %C\n"), this->file_)); 02412 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_ = %s\n"), this->msg_)); 02413 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d\n"), this->restart_)); 02414 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nostream_ = %@\n"), this->ostream_)); 02415 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_callback_ = %@\n"), 02416 this->msg_callback_)); 02417 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nprogram_name_ = %s\n"), 02418 this->program_name_ ? this->program_name_ 02419 : ACE_TEXT ("<unknown>"))); 02420 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nlocal_host_ = %s\n"), 02421 this->local_host_ ? this->local_host_ 02422 : ACE_TEXT ("<unknown>"))); 02423 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npid_ = %d\n"), this->getpid ())); 02424 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = 0x%x\n"), this->flags_)); 02425 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_depth_ = %d\n"), 02426 this->trace_depth_)); 02427 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntrace_active_ = %d\n"), 02428 this->trace_active_)); 02429 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntracing_enabled_ = %d\n"), 02430 this->tracing_enabled_)); 02431 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\npriority_mask_ = 0x%x\n"), 02432 this->priority_mask_)); 02433 if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0) 02434 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_state_ = %d\n"), 02435 this->thr_desc_->state ())); 02436 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmsg_off_ = %d\n"), this->msg_off_)); 02437 02438 // Be sure that there is a message_queue_, with multiple threads. 02439 ACE_MT (ACE_Log_Msg_Manager::init_backend ()); 02440 02441 ACE_MT (ACE_Log_Msg_Manager::get_lock ()->dump ()); 02442 // Synchronize output operations. 02443 02444 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 02445 #endif /* ACE_HAS_DUMP */ 02446 }
| void ACE_Log_Msg::enable_debug_messages | ( | ACE_Log_Priority | priority = LM_DEBUG |
) | [static] |
Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances.
Definition at line 415 of file Log_Msg.cpp.
00416 { 00417 ACE_SET_BITS (ACE_Log_Msg::default_priority_mask_, priority); 00418 ACE_Log_Msg *i = ACE_Log_Msg::instance (); 00419 i->priority_mask (i->priority_mask () | priority); 00420 }
| int ACE_Log_Msg::errnum | ( | void | ) | const |
Get the value of the errnum (by convention this corresponds to errno).
Definition at line 58 of file Log_Msg.inl.
00059 { 00060 return this->errnum_; 00061 }
| void ACE_Log_Msg::errnum | ( | int | e | ) |
Set the value of the errnum (by convention this corresponds to errno).
Definition at line 65 of file Log_Msg.inl.
00066 { 00067 this->errnum_ = e; 00068 }
| int ACE_Log_Msg::exists | ( | void | ) | [static] |
Returns non-null if an ACE_Log_Msg exists for the calling thread.
Definition at line 266 of file Log_Msg.cpp.
00267 { 00268 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00269 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ 00270 defined (ACE_HAS_TSS_EMULATION) 00271 void *tss_log_msg = 0; // The actual type is ACE_Log_Msg*, but we need this 00272 // void to keep G++ from complaining. 00273 00274 // Get the tss_log_msg from thread-specific storage. 00275 return ACE_Log_Msg::key_created_ 00276 && ACE_Thread::getspecific (*(log_msg_tss_key ()), &tss_log_msg) != -1 00277 && tss_log_msg != 0; 00278 # else 00279 # error "Platform must support thread-specific storage if threads are used." 00280 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ 00281 #else /* ! ACE_MT_SAFE */ 00282 return 1; 00283 #endif /* ! ACE_MT_SAFE */ 00284 }
| const char * ACE_Log_Msg::file | ( | void | ) |
Get the file name where an error occurred.
Definition at line 158 of file Log_Msg.inl.
00159 { 00160 return this->file_; 00161 }
| void ACE_Log_Msg::file | ( | const char * | s | ) |
Set the file name where an error occurred.
Definition at line 165 of file Log_Msg.inl.
00166 { 00167 ACE_OS::strsncpy (this->file_, s, sizeof this->file_); 00168 }
| u_long ACE_Log_Msg::flags | ( | void | ) |
Return the bits in the logger's options flags.
Definition at line 568 of file Log_Msg.cpp.
00569 { 00570 ACE_TRACE ("ACE_Log_Msg::flags"); 00571 u_long result; 00572 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00573 *ACE_Log_Msg_Manager::get_lock (), 0)); 00574 00575 result = ACE_Log_Msg::flags_; 00576 return result; 00577 }
| pid_t ACE_Log_Msg::getpid | ( | void | ) | const |
Optimize reading of the pid (avoids a system call if the value is cached...).
Definition at line 224 of file Log_Msg.inl.
00225 { 00226 if (ACE_Log_Msg::pid_ == -2) 00227 ACE_Log_Msg::pid_ = ACE_OS::getpid (); 00228 00229 return ACE_Log_Msg::pid_; 00230 }
| int ACE_Log_Msg::inc | ( | void | ) |
Nesting depth increment.
Definition at line 86 of file Log_Msg.inl.
00087 { 00088 return this->trace_depth_++; 00089 }
| void ACE_Log_Msg::inherit_hook | ( | ACE_OS_Thread_Descriptor * | thr_desc, | |
| ACE_OS_Log_Msg_Attributes & | attributes | |||
| ) | [static] |
Inherit hook, the attributes field is a ACE_OS_Log_Msg_Attributes object, invoke the inherit_log_msg() method on it, then destroy it and set the attribute argument to 0.
Definition at line 2605 of file Log_Msg.cpp.
02607 { 02608 #if !defined (ACE_THREADS_DONT_INHERIT_LOG_MSG) && \ 02609 !defined (ACE_HAS_MINIMAL_ACE_OS) 02610 // Inherit the logging features if the parent thread has an 02611 // <ACE_Log_Msg>. Note that all of the following operations occur 02612 // within thread-specific storage. 02613 ACE_Log_Msg *new_log = ACE_LOG_MSG; 02614 02615 // Note that we do not inherit the callback because this might have 02616 // been allocated off of the stack of the original thread, in which 02617 // case all hell would break loose... 02618 02619 if (attributes.ostream_) 02620 { 02621 new_log->ostream_ = attributes.ostream_; 02622 new_log->ostream_refcount_ = 02623 static_cast<Atomic_ULong *> (attributes.ostream_refcount_); 02624 02625 new_log->priority_mask (attributes.priority_mask_); 02626 02627 if (attributes.tracing_enabled_) 02628 new_log->start_tracing (); 02629 02630 new_log->restart (attributes.restart_); 02631 new_log->trace_depth (attributes.trace_depth_); 02632 } 02633 02634 // @@ Now the TSS Log_Msg has been created, cache my thread 02635 // descriptor in. 02636 02637 if (thr_desc != 0) 02638 // This downcast is safe. We do it to avoid having to #include 02639 // ace/Thread_Manager.h. 02640 new_log->thr_desc (static_cast<ACE_Thread_Descriptor *> (thr_desc)); 02641 // Block the thread from proceeding until 02642 // thread manager has thread descriptor ready. 02643 #endif /* ! ACE_THREADS_DONT_INHERIT_LOG_MSG && ! ACE_HAS_MINIMAL_ACE_OS */ 02644 }
| static void ACE_Log_Msg::init_hook | ( | ACE_OS_Log_Msg_Attributes &attributes#if | definedACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS, | |
| ACE_SEH_EXCEPT_HANDLER | selector = 0, |
|||
| ACE_SEH_EXCEPT_HANDLER | handler = 0#endif | |||
| ) | [static] |
| handler | Init hook, create a Log_Msg_Attribute object, initialize its attributes from the TSS Log_Msg and save the object in the attributes argument |
| ACE_Log_Msg * ACE_Log_Msg::instance | ( | void | ) | [static] |
Returns a pointer to the Singleton.
Definition at line 287 of file Log_Msg.cpp.
00288 { 00289 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00290 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ 00291 defined (ACE_HAS_TSS_EMULATION) 00292 // TSS Singleton implementation. 00293 00294 if (!ACE_Log_Msg::key_created_) 00295 { 00296 ACE_thread_mutex_t *lock = 00297 reinterpret_cast<ACE_thread_mutex_t *> ( 00298 ACE_OS_Object_Manager::preallocated_object 00299 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]); 00300 00301 if (1 == ACE_OS_Object_Manager::starting_up()) 00302 //This function is called before ACE_OS_Object_Manager is 00303 //initialized. So the lock might not be valid. Assume it's 00304 //single threaded and so don't need the lock. 00305 ; 00306 else 00307 ACE_OS::thread_mutex_lock (lock); 00308 00309 if (!ACE_Log_Msg::key_created_) 00310 { 00311 // Allocate the Singleton lock. 00312 ACE_Log_Msg_Manager::get_lock (); 00313 00314 { 00315 ACE_NO_HEAP_CHECK; 00316 if (ACE_Thread::keycreate (log_msg_tss_key (), 00317 &ACE_TSS_CLEANUP_NAME) != 0) 00318 { 00319 if (1 == ACE_OS_Object_Manager::starting_up()) 00320 //This function is called before ACE_OS_Object_Manager is 00321 //initialized. So the lock might not be valid. Assume it's 00322 //single threaded and so don't need the lock. 00323 ; 00324 else 00325 ACE_OS::thread_mutex_unlock (lock); 00326 return 0; // Major problems, this should *never* happen! 00327 } 00328 } 00329 00330 ACE_Log_Msg::key_created_ = true; 00331 } 00332 00333 if (1 == ACE_OS_Object_Manager::starting_up()) 00334 //This function is called before ACE_OS_Object_Manager is 00335 //initialized. So the lock might not be valid. Assume it's 00336 //single threaded and so don't need the lock. 00337 ; 00338 else 00339 ACE_OS::thread_mutex_unlock (lock); 00340 } 00341 00342 ACE_Log_Msg *tss_log_msg = 0; 00343 void *temp = 0; 00344 00345 // Get the tss_log_msg from thread-specific storage. 00346 if (ACE_Thread::getspecific (*(log_msg_tss_key ()), &temp) == -1) 00347 return 0; // This should not happen! 00348 00349 tss_log_msg = static_cast <ACE_Log_Msg *> (temp); 00350 00351 // Check to see if this is the first time in for this thread. 00352 if (tss_log_msg == 0) 00353 { 00354 // Allocate memory off the heap and store it in a pointer in 00355 // thread-specific storage (on the stack...). Stop heap 00356 // checking, the memory will always be freed by the thread 00357 // rundown because of the TSS callback set up when the key was 00358 // created. This prevents from getting these blocks reported as 00359 // memory leaks. 00360 { 00361 ACE_NO_HEAP_CHECK; 00362 00363 ACE_NEW_RETURN (tss_log_msg, 00364 ACE_Log_Msg, 00365 0); 00366 // Store the dynamically allocated pointer in thread-specific 00367 // storage. It gets deleted via the ACE_TSS_cleanup function 00368 // when the thread terminates. 00369 00370 if (ACE_Thread::setspecific (*(log_msg_tss_key()), 00371 reinterpret_cast<void *> (tss_log_msg)) 00372 != 0) 00373 return 0; // Major problems, this should *never* happen! 00374 } 00375 } 00376 00377 return tss_log_msg; 00378 # else 00379 # error "Platform must support thread-specific storage if threads are used." 00380 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ 00381 #else /* ! ACE_MT_SAFE */ 00382 // We don't have threads, we cannot call 00383 // ACE_Log_Msg_Manager::get_lock () to initialize the logger 00384 // callback, so instead we do it here. 00385 if (ACE_Log_Msg_Manager::init_backend () == -1) 00386 return 0; 00387 00388 // Singleton implementation. 00389 00390 if (log_msg_cleanup == 0) 00391 { 00392 ACE_NEW_RETURN (log_msg_cleanup, ACE_Msg_Log_Cleanup, 0); 00393 // Register the instance for destruction at program termination. 00394 ACE_Object_Manager::at_exit (log_msg_cleanup, 00395 0, 00396 typeid (*log_msg_cleanup).name ()); 00397 } 00398 00399 return &log_msg_cleanup->object (); 00400 #endif /* ! ACE_MT_SAFE */ 00401 }
| int ACE_Log_Msg::last_error_adapter | ( | void | ) | [static] |
Returns last error.
Definition at line 406 of file Log_Msg.cpp.
00407 { 00408 return ACE_OS::last_error (); 00409 }
| int ACE_Log_Msg::linenum | ( | void | ) | const |
Get the line number where an error occurred.
Definition at line 72 of file Log_Msg.inl.
00073 { 00074 return this->linenum_; 00075 }
| void ACE_Log_Msg::linenum | ( | int | l | ) |
Set the line number where an error occurred.
Definition at line 79 of file Log_Msg.inl.
00080 { 00081 this->linenum_ = l; 00082 }
| void ACE_Log_Msg::local_host | ( | const ACE_TCHAR * | s | ) |
Set the name of the local host.
Definition at line 2539 of file Log_Msg.cpp.
02540 { 02541 if (s) 02542 { 02543 ACE_OS::free ((void *) ACE_Log_Msg::local_host_); 02544 { 02545 ACE_NO_HEAP_CHECK; 02546 02547 ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s)); 02548 } 02549 } 02550 }
| const ACE_TCHAR * ACE_Log_Msg::local_host | ( | void | ) | const |
Get the name of the local host.
Definition at line 217 of file Log_Msg.inl.
00218 { 00219 return ACE_Log_Msg::local_host_; 00220 }
| ssize_t ACE_Log_Msg::log | ( | ACE_Log_Record & | log_record, | |
| int | suppress_stderr = 0 | |||
| ) |
Log a custom built log record to the currently enabled logging sinks.
Definition at line 2222 of file Log_Msg.cpp.
02224 { 02225 ssize_t result = 0; 02226 02227 // Format the message and print it to stderr and/or ship it off to 02228 // the log_client daemon, and/or print it to the ostream. Of 02229 // course, only print the message if "SILENT" mode is disabled. 02230 if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_, 02231 ACE_Log_Msg::SILENT)) 02232 { 02233 bool tracing = this->tracing_enabled (); 02234 this->stop_tracing (); 02235 02236 #if !defined (ACE_WIN32) 02237 // Make this block signal-safe. 02238 ACE_Log_Msg_Sig_Guard sb; 02239 #endif /* !ACE_WIN32 */ 02240 02241 // Do the callback, if needed, before acquiring the lock 02242 // to avoid holding the lock during the callback so we don't 02243 // have deadlock if the callback uses the logger. 02244 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, 02245 ACE_Log_Msg::MSG_CALLBACK) 02246 && this->msg_callback () != 0) 02247 this->msg_callback ()->log (log_record); 02248 02249 // Make sure that the lock is held during all this. 02250 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 02251 *ACE_Log_Msg_Manager::get_lock (), 02252 -1)); 02253 02254 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, 02255 ACE_Log_Msg::STDERR) 02256 && !suppress_stderr) // This is taken care of by our caller. 02257 log_record.print (ACE_Log_Msg::local_host_, 02258 ACE_Log_Msg::flags_, 02259 stderr); 02260 02261 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) || 02262 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG) || 02263 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER)) 02264 { 02265 // Be sure that there is a message_queue_, with multiple threads. 02266 ACE_MT (ACE_Log_Msg_Manager::init_backend ()); 02267 } 02268 02269 02270 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) || 02271 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG)) 02272 { 02273 result = 02274 ACE_Log_Msg_Manager::log_backend_->log (log_record); 02275 } 02276 02277 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) && 02278 ACE_Log_Msg_Manager::custom_backend_ != 0) 02279 { 02280 result = 02281 ACE_Log_Msg_Manager::custom_backend_->log (log_record); 02282 } 02283 02284 // This must come last, after the other two print operations 02285 // (see the <ACE_Log_Record::print> method for details). 02286 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, 02287 ACE_Log_Msg::OSTREAM) 02288 && this->msg_ostream () != 0) 02289 log_record.print (ACE_Log_Msg::local_host_, 02290 ACE_Log_Msg::flags_, 02291 #if defined (ACE_LACKS_IOSTREAM_TOTALLY) 02292 static_cast<FILE *> (this->msg_ostream ()) 02293 #else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ 02294 *this->msg_ostream () 02295 #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ 02296 ); 02297 02298 if (tracing) 02299 this->start_tracing (); 02300 } 02301 02302 return result; 02303 }
| ssize_t ACE_Log_Msg::log | ( | const ACE_TCHAR * | format, | |
| ACE_Log_Priority | priority, | |||
| va_list | argp | |||
| ) |
An alternative logging mechanism that makes it possible to integrate variable argument lists from other logging mechanisms into the ACE mechanism.
Definition at line 978 of file Log_Msg.cpp.
00981 { 00982 ACE_TRACE ("ACE_Log_Msg::log"); 00983 // External decls. 00984 00985 typedef void (*PTF)(...); 00986 00987 // Check if there were any conditional values set. 00988 bool const conditional_values = this->conditional_values_.is_set_; 00989 00990 // Reset conditional values. 00991 this->conditional_values_.is_set_ = false; 00992 00993 // Only print the message if <priority_mask_> hasn't been reset to 00994 // exclude this logging priority. 00995 if (this->log_priority_enabled (log_priority) == 0) 00996 return 0; 00997 00998 // If conditional values were set and the log priority is correct, 00999 // then the values are actually set. 01000 if (conditional_values) 01001 this->set (this->conditional_values_.file_, 01002 this->conditional_values_.line_, 01003 this->conditional_values_.op_status_, 01004 this->conditional_values_.errnum_, 01005 this->restart (), 01006 this->msg_ostream (), 01007 this->msg_callback ()); 01008 01009 // Logging is supposed to be a benign activity (i.e., not interfer 01010 // with normal application operations), so don't inadvertently smash 01011 // errno! 01012 ACE_Errno_Guard guard (errno); 01013 01014 ACE_Log_Record log_record (log_priority, 01015 ACE_OS::gettimeofday (), 01016 this->getpid ()); 01017 01018 // bp is pointer to where to put next part of logged message. 01019 // bspace is the number of characters remaining in msg_. 01020 ACE_TCHAR *bp = const_cast<ACE_TCHAR *> (this->msg ()); 01021 size_t bspace = ACE_MAXLOGMSGLEN; // Leave room for Nul term. 01022 if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN) 01023 bspace -= static_cast<size_t> (this->msg_off_); 01024 01025 // If this platform has snprintf() capability to prevent overrunning the 01026 // output buffer, use it. To avoid adding a maintenance-hassle compile- 01027 // time couple between here and OS.cpp, don't try to figure this out at 01028 // compile time. Instead, do a quick check now; if we get a -1 return, 01029 // the platform doesn't support the length-limiting capability. 01030 ACE_TCHAR test[2]; 01031 bool can_check = ACE_OS::snprintf (test, 1, ACE_TEXT ("x")) != -1; 01032 01033 bool abort_prog = false; 01034 int exit_value = 0; 01035 01036 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE)) 01037 { 01038 // Prepend the program name onto this message 01039 01040 if (ACE_Log_Msg::program_name_ != 0) 01041 { 01042 for (const ACE_TCHAR *s = ACE_Log_Msg::program_name_; 01043 bspace > 1 && (*bp = *s) != '\0'; 01044 ++s, --bspace) 01045 bp++; 01046 01047 *bp++ = '|'; 01048 --bspace; 01049 } 01050 } 01051 01052 if (timestamp_ > 0) 01053 { 01054 ACE_TCHAR day_and_time[35]; 01055 const ACE_TCHAR *s = 0; 01056 if (timestamp_ == 1) 01057 { 01058 // Print just the time 01059 s = ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR), 1); 01060 } 01061 else 01062 { 01063 // Print time and date 01064 ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR)); 01065 s = day_and_time; 01066 } 01067 01068 for (; bspace > 1 && (*bp = *s) != '\0'; ++s, --bspace) 01069 ++bp; 01070 01071 *bp++ = '|'; 01072 --bspace; 01073 } 01074 01075 while (*format_str != '\0' && bspace > 0) 01076 { 01077 // Copy input to output until we encounter a %, however a 01078 // % followed by another % is not a format specification. 01079 01080 if (*format_str != '%') 01081 { 01082 *bp++ = *format_str++; 01083 --bspace; 01084 } 01085 else if (format_str[1] == '%') // An "escaped" '%' (just print one '%'). 01086 { 01087 *bp++ = *format_str++; // Store first % 01088 ++format_str; // but skip second % 01089 --bspace; 01090 } 01091 else 01092 { 01093 // This is most likely a format specification that ends with 01094 // one of the valid options described previously. To enable full 01095 // use of all sprintf capabilities, save the format specifier 01096 // from the '%' up to the format letter in a new char array. 01097 // This allows the full sprintf capability for padding, field 01098 // widths, alignment, etc. Any width/precision requiring a 01099 // caller-supplied argument is extracted and placed as text 01100 // into the format array. Lastly, we convert the caller-supplied 01101 // format specifier from the ACE_Log_Msg-supported list to the 01102 // equivalent sprintf specifier, and run the new format spec 01103 // through sprintf, adding it to the bp string. 01104 01105 const ACE_TCHAR *abort_str = ACE_TEXT ("Aborting..."); 01106 const ACE_TCHAR *start_format = format_str; 01107 ACE_TCHAR format[128]; // Converted format string 01108 ACE_TCHAR *fp; // Current format pointer 01109 int wp = 0; // Width/precision extracted from args 01110 bool done = false; 01111 bool skip_nul_locate = false; 01112 int this_len = 0; // How many chars s[n]printf wrote 01113 01114 fp = format; 01115 *fp++ = *format_str++; // Copy in the % 01116 01117 // Initialization to satisfy VC6 01118 int tmp_indent = 0; 01119 // Work through the format string to copy in the format 01120 // from the caller. While it's going across, extract ints 01121 // for '*' width/precision values from the argument list. 01122 // When the real format specifier is located, change it to 01123 // one recognized by sprintf, if needed, and do the sprintf 01124 // call. 01125 01126 while (!done) 01127 { 01128 done = true; // Unless a conversion spec changes it 01129 01130 switch (*format_str) 01131 { 01132 // The initial set of cases are the conversion 01133 // specifiers. Copy them in to the format array. 01134 // Note we don't use 'l', a normal conversion spec, 01135 // as a conversion because it is a ACE_Log_Msg format 01136 // specifier. 01137 case '-': 01138 case '+': 01139 case '0': 01140 case ' ': 01141 case '#': 01142 case '1': 01143 case '2': 01144 case '3': 01145 case '4': 01146 case '5': 01147 case '6': 01148 case '7': 01149 case '8': 01150 case '9': 01151 case '.': 01152 case 'L': 01153 case 'h': 01154 *fp++ = *format_str; 01155 done = false; 01156 break; 01157 01158 case '*': 01159 wp = va_arg (argp, int); 01160 ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp); 01161 fp += ACE_OS::strlen (fp); 01162 done = false; 01163 break; 01164 01165 case 'A': // ACE_timer_t 01166 { 01167 ACE_OS::strcpy (fp, ACE_TEXT ("f")); 01168 double value = va_arg (argp, double); 01169 if (can_check) 01170 this_len = ACE_OS::snprintf (bp, bspace, format, value); 01171 else 01172 this_len = ACE_OS::sprintf (bp, format, value); 01173 ACE_UPDATE_COUNT (bspace, this_len); 01174 } 01175 break; 01176 01177 case 'a': // Abort program after handling all of format string. 01178 abort_prog = true; 01179 exit_value = va_arg (argp, int); 01180 ACE_OS::strsncpy (bp, abort_str, bspace); 01181 if (bspace > ACE_OS::strlen (abort_str)) 01182 bspace -= ACE_OS::strlen (abort_str); 01183 else 01184 bspace = 0; 01185 break; 01186 01187 case 'l': // Source file line number 01188 ACE_OS::strcpy (fp, ACE_TEXT ("d")); 01189 if (can_check) 01190 this_len = ACE_OS::snprintf (bp, 01191 bspace, 01192 format, 01193 this->linenum ()); 01194 else 01195 this_len = ACE_OS::sprintf (bp, format, this->linenum ()); 01196 ACE_UPDATE_COUNT (bspace, this_len); 01197 break; 01198 01199 case 'N': // Source file name 01200 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01201 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01202 #else 01203 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01204 #endif 01205 if (can_check) 01206 this_len = ACE_OS::snprintf (bp, bspace, format, 01207 this->file () ? 01208 ACE_TEXT_CHAR_TO_TCHAR (this->file ()) 01209 : ACE_TEXT ("<unknown file>")); 01210 else 01211 this_len = ACE_OS::sprintf (bp, format, 01212 this->file () ? 01213 ACE_TEXT_CHAR_TO_TCHAR (this->file ()) 01214 : ACE_TEXT ("<unknown file>")); 01215 ACE_UPDATE_COUNT (bspace, this_len); 01216 break; 01217 01218 case 'n': // Program name 01219 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01220 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01221 #else /* ACE_WIN32 && ACE_USES_WCHAR */ 01222 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01223 #endif 01224 if (can_check) 01225 this_len = ACE_OS::snprintf (bp, bspace, format, 01226 ACE_Log_Msg::program_name_ ? 01227 ACE_Log_Msg::program_name_ : 01228 ACE_TEXT ("<unknown>")); 01229 else 01230 this_len = ACE_OS::sprintf (bp, format, 01231 ACE_Log_Msg::program_name_ ? 01232 ACE_Log_Msg::program_name_ : 01233 ACE_TEXT ("<unknown>")); 01234 ACE_UPDATE_COUNT (bspace, this_len); 01235 break; 01236 01237 case 'P': // Process ID 01238 #if defined (ACE_OPENVMS) 01239 // Print the process id in hex on OpenVMS. 01240 ACE_OS::strcpy (fp, ACE_TEXT ("x")); 01241 #else 01242 ACE_OS::strcpy (fp, ACE_TEXT ("d")); 01243 #endif 01244 if (can_check) 01245 this_len = ACE_OS::snprintf 01246 (bp, bspace, format, 01247 static_cast<int> (this->getpid ())); 01248 else 01249 this_len = ACE_OS::sprintf 01250 (bp, format, static_cast<int> (this->getpid ())); 01251 ACE_UPDATE_COUNT (bspace, this_len); 01252 break; 01253 01254 case 'p': // <errno> string, ala perror() 01255 { 01256 errno = 0; 01257 char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); 01258 // Windows can try to translate the errnum using 01259 // system calls if strerror() doesn't get anything useful. 01260 #if defined (ACE_WIN32) 01261 if (errno == 0) 01262 { 01263 #endif 01264 01265 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01266 ACE_OS::strcpy (fp, ACE_TEXT ("ls: %ls")); 01267 wchar_t *str = va_arg (argp, wchar_t *); 01268 #else 01269 ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); 01270 ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *); 01271 #endif 01272 if (can_check) 01273 this_len = ACE_OS::snprintf 01274 (bp, bspace, format, 01275 str ? str : ACE_TEXT ("(null)"), 01276 ACE_TEXT_CHAR_TO_TCHAR (msg)); 01277 else 01278 this_len = ACE_OS::sprintf 01279 (bp, format, 01280 str ? str : ACE_TEXT ("(null)"), 01281 ACE_TEXT_CHAR_TO_TCHAR (msg)); 01282 #if defined (ACE_WIN32) 01283 } 01284 else 01285 { 01286 errno = ACE::map_errno (this->errnum ()); 01287 ACE_TCHAR *lpMsgBuf = 0; 01288 01289 // PharLap can't do FormatMessage, so try for socket 01290 // error. 01291 # if !defined (ACE_HAS_PHARLAP) 01292 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER 01293 | FORMAT_MESSAGE_MAX_WIDTH_MASK 01294 | FORMAT_MESSAGE_FROM_SYSTEM, 01295 0, 01296 errno, 01297 MAKELANGID (LANG_NEUTRAL, 01298 SUBLANG_DEFAULT), 01299 // Default language 01300 (ACE_TCHAR *) &lpMsgBuf, 01301 0, 01302 0); 01303 # endif /* ACE_HAS_PHARLAP */ 01304 01305 // If we don't get a valid response from 01306 // <FormatMessage>, we'll assume this is a 01307 // WinSock error and so we'll try to convert 01308 // it into a string. If this doesn't work it 01309 // returns "unknown error" which is fine for 01310 // our purposes. 01311 ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *); 01312 if (lpMsgBuf == 0) 01313 { 01314 const ACE_TCHAR *message = 01315 ACE::sock_error (errno); 01316 ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); 01317 if (can_check) 01318 this_len = ACE_OS::snprintf 01319 (bp, bspace, format, 01320 str ? str : ACE_TEXT ("(null)"), 01321 message); 01322 else 01323 this_len = ACE_OS::sprintf 01324 (bp, format, 01325 str ? str : ACE_TEXT ("(null)"), 01326 message); 01327 } 01328 else 01329 { 01330 ACE_OS::strcpy (fp, ACE_TEXT ("s: %s")); 01331 if (can_check) 01332 this_len = ACE_OS::snprintf 01333 (bp, bspace, format, 01334 str ? str : ACE_TEXT ("(null)"), 01335 lpMsgBuf); 01336 else 01337 this_len = ACE_OS::sprintf 01338 (bp, format, 01339 str ? str : ACE_TEXT ("(null)"), 01340 lpMsgBuf); 01341 // Free the buffer. 01342 ::LocalFree (lpMsgBuf); 01343 } 01344 } 01345 #endif /* ACE_WIN32 */ 01346 ACE_UPDATE_COUNT (bspace, this_len); 01347 break; 01348 } 01349 01350 case 'M': // Print the name of the priority of the message. 01351 01352 // Look at the format precision specifier. .1 is interpreted 01353 // as a single character printout, otherwise we print the name of 01354 // the priority. 01355 01356 // So, did we find a .1 specifier? Do we need to override it? 01357 if (format[1] == ACE_TEXT('.') && 01358 format[2] == ACE_TEXT('1')) 01359 { 01360 // Yup. 01361 // Print a single character signifying the severity of the message 01362 fp = format; 01363 fp++; 01364 01365 # if defined (ACE_USES_WCHAR) 01366 01367 # if defined (ACE_WIN32) // Windows uses 'c' for a wide character 01368 ACE_OS::strcpy (fp, ACE_TEXT ("c")); 01369 # else // Other platforms behave differently 01370 # if defined (HPUX) // HP-Unix compatible 01371 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01372 # else // Other 01373 ACE_OS::strcpy (fp, ACE_TEXT ("lc")); 01374 # endif /* HPUX */ 01375 # endif 01376 01377 # else /* ACE_USES_WCHAR */ 01378 01379 // Non-unicode builds simply use a standard character format specifier 01380 ACE_OS::strcpy (fp, ACE_TEXT ("c")); 01381 01382 # endif /* ACE_USES_WCHAR */ 01383 01384 // Below is an optimized (binary search based) 01385 // version of the following simple piece of code: 01386 // 01387 // log_priority == LM_SHUTDOWN ? 'S' : // Shutdown 01388 // log_priority == LM_TRACE ? 'T' : // Trace 01389 // log_priority == LM_DEBUG ? 'D' : // Debug 01390 // log_priority == LM_INFO ? 'I' : // Info 01391 // log_priority == LM_NOTICE ? 'N' : // Notice 01392 // log_priority == LM_WARNING ? 'W' : // Warning 01393 // log_priority == LM_STARTUP ? 'U' : // Startup 01394 // log_priority == LM_ERROR ? 'E' : // Error 01395 // log_priority == LM_CRITICAL ? 'C' : // Critical 01396 // log_priority == LM_ALERT ? 'A' : // Alert 01397 // log_priority == LM_EMERGENCY ? '!' : // Emergency 01398 // '?' // Unknown 01399 01400 if (can_check) 01401 { 01402 this_len = ACE_OS::snprintf 01403 (bp, bspace, format, 01404 #if !defined (ACE_USES_WCHAR) || defined (ACE_WIN32) 01405 (int) 01406 #else 01407 (wint_t) 01408 #endif 01409 (log_priority <= LM_WARNING) ? 01410 (log_priority <= LM_DEBUG) ? 01411 (log_priority <= LM_TRACE) ? 01412 (log_priority == LM_SHUTDOWN) ? 01413 ACE_TEXT('S') : ACE_TEXT('T') : ACE_TEXT('D') : 01414 (log_priority <= LM_NOTICE) ? 01415 (log_priority == LM_INFO) ? 01416 ACE_TEXT('I') : ACE_TEXT('N') : ACE_TEXT('W') : 01417 (log_priority <= LM_CRITICAL) ? 01418 (log_priority <= LM_ERROR) ? 01419 (log_priority == LM_STARTUP) ? 01420 ACE_TEXT('U') : ACE_TEXT('E') : ACE_TEXT('C') : 01421 (log_priority <= LM_EMERGENCY) ? 01422 (log_priority == LM_ALERT) ? 01423 ACE_TEXT('A') : ACE_TEXT('!') : ACE_TEXT('?')); 01424 } 01425 else 01426 { 01427 this_len = ACE_OS::sprintf 01428 (bp, format, 01429 #if !defined (ACE_USES_WCHAR) || defined (ACE_WIN32) 01430 (int) 01431 #else 01432 (wint_t) 01433 #endif 01434 (log_priority <= LM_WARNING) ? 01435 (log_priority <= LM_DEBUG) ? 01436 (log_priority <= LM_TRACE) ? 01437 (log_priority == LM_SHUTDOWN) ? 01438 ACE_TEXT('S') : ACE_TEXT('T') : ACE_TEXT('D') : 01439 (log_priority <= LM_NOTICE) ? 01440 (log_priority == LM_INFO) ? 01441 ACE_TEXT('I') : ACE_TEXT('N') : ACE_TEXT('W') : 01442 (log_priority <= LM_CRITICAL) ? 01443 (log_priority <= LM_ERROR) ? 01444 (log_priority == LM_STARTUP) ? 01445 ACE_TEXT('U') : ACE_TEXT('E') : ACE_TEXT('C') : 01446 (log_priority <= LM_EMERGENCY) ? 01447 (log_priority == LM_ALERT) ? 01448 ACE_TEXT('A') : ACE_TEXT('!') : ACE_TEXT('?')); 01449 } 01450 01451 ACE_UPDATE_COUNT (bspace, this_len); 01452 } 01453 else 01454 { 01455 // Nope, print out standard priority_name() string 01456 01457 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01458 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01459 #else 01460 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01461 #endif 01462 if (can_check) 01463 this_len = ACE_OS::snprintf 01464 (bp, bspace, format, 01465 ACE_Log_Record::priority_name (log_priority)); 01466 else 01467 this_len = ACE_OS::sprintf 01468 (bp, format, 01469 ACE_Log_Record::priority_name (log_priority)); 01470 ACE_UPDATE_COUNT (bspace, this_len); 01471 } 01472 break; 01473 01474 case 'm': // Format the string assocated with the errno value. 01475 { 01476 errno = 0; 01477 char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ())); 01478 // Windows can try to translate the errnum using 01479 // system calls if strerror() doesn't get anything useful. 01480 #if defined (ACE_WIN32) 01481 if (errno == 0) 01482 { 01483 #endif 01484 01485 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01486 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01487 #else /* ACE_WIN32 && ACE_USES_WCHAR */ 01488 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01489 #endif 01490 if (can_check) 01491 this_len = ACE_OS::snprintf 01492 (bp, bspace, format, ACE_TEXT_CHAR_TO_TCHAR (msg)); 01493 else 01494 this_len = ACE_OS::sprintf 01495 (bp, format, ACE_TEXT_CHAR_TO_TCHAR (msg)); 01496 #if defined (ACE_WIN32) 01497 } 01498 else 01499 { 01500 errno = ACE::map_errno (this->errnum ()); 01501 ACE_TCHAR *lpMsgBuf = 0; 01502 01503 // PharLap can't do FormatMessage, so try for socket 01504 // error. 01505 # if !defined (ACE_HAS_PHARLAP) 01506 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER 01507 | FORMAT_MESSAGE_MAX_WIDTH_MASK 01508 | FORMAT_MESSAGE_FROM_SYSTEM, 01509 0, 01510 errno, 01511 MAKELANGID (LANG_NEUTRAL, 01512 SUBLANG_DEFAULT), 01513 // Default language 01514 (ACE_TCHAR *) &lpMsgBuf, 01515 0, 01516 0); 01517 # endif /* ACE_HAS_PHARLAP */ 01518 01519 // If we don't get a valid response from 01520 // <FormatMessage>, we'll assume this is a 01521 // WinSock error and so we'll try to convert 01522 // it into a string. If this doesn't work it 01523 // returns "unknown error" which is fine for 01524 // our purposes. 01525 if (lpMsgBuf == 0) 01526 { 01527 const ACE_TCHAR *message = 01528 ACE::sock_error (errno); 01529 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01530 if (can_check) 01531 this_len = ACE_OS::snprintf 01532 (bp, bspace, format, message); 01533 else 01534 this_len = ACE_OS::sprintf (bp, format, message); 01535 } 01536 else 01537 { 01538 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01539 if (can_check) 01540 this_len = ACE_OS::snprintf 01541 (bp, bspace, format, lpMsgBuf); 01542 else 01543 this_len = ACE_OS::sprintf 01544 (bp, format, lpMsgBuf); 01545 // Free the buffer. 01546 ::LocalFree (lpMsgBuf); 01547 } 01548 } 01549 #endif /* ACE_WIN32 */ 01550 ACE_UPDATE_COUNT (bspace, this_len); 01551 break; 01552 } 01553 01554 case 'R': // Format the return status of the operation. 01555 this->op_status (va_arg (argp, int)); 01556 ACE_OS::strcpy (fp, ACE_TEXT ("d")); 01557 if (can_check) 01558 this_len = ACE_OS::snprintf 01559 (bp, bspace, format, this->op_status ()); 01560 else 01561 this_len = ACE_OS::sprintf 01562 (bp, format, this->op_status ()); 01563 ACE_UPDATE_COUNT (bspace, this_len); 01564 break; 01565 01566 case '{': // Increment the trace_depth, then indent 01567 skip_nul_locate = true; 01568 (void) this->inc (); 01569 break; 01570 01571 case '}': // indent, then decrement trace_depth 01572 skip_nul_locate = true; 01573 (void) this->dec (); 01574 break; 01575 01576 case '$': // insert a newline, then indent the next line 01577 // according to %I 01578 *bp++ = '\n'; 01579 --bspace; 01580 /* fallthrough */ 01581 01582 case 'I': // Indent with nesting_depth*width spaces 01583 // Caller can do %*I to override nesting indent, and 01584 // if %*I was done, wp has the extracted width. 01585 #if defined (ACE_HAS_TRACE) 01586 if (0 == wp) 01587 wp = ACE_Trace::get_nesting_indent (); 01588 #else 01589 if (0 == wp) 01590 wp = 4; 01591 #endif /* ACE_HAS_TRACE */ 01592 wp *= this->trace_depth_; 01593 if (static_cast<size_t> (wp) > bspace) 01594 wp = static_cast<int> (bspace); 01595 for (tmp_indent = wp; 01596 tmp_indent; 01597 --tmp_indent) 01598 *bp++ = ' '; 01599 01600 *bp = '\0'; 01601 bspace -= static_cast<size_t> (wp); 01602 skip_nul_locate = true; 01603 break; 01604 01605 case 'r': // Run (invoke) this subroutine. 01606 { 01607 ptrdiff_t const osave = ACE_Log_Msg::msg_off_; 01608 01609 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, 01610 ACE_Log_Msg::SILENT) && 01611 bspace > 1) 01612 { 01613 *bp++ = '{'; 01614 --bspace; 01615 } 01616 ACE_Log_Msg::msg_off_ = bp - this->msg_; 01617 01618 (*va_arg (argp, PTF))(); 01619 01620 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, 01621 ACE_Log_Msg::SILENT) && 01622 bspace > (1 + ACE_OS::strlen (bp))) 01623 { 01624 bspace -= (ACE_OS::strlen (bp) + 1); 01625 bp += ACE_OS::strlen (bp); 01626 *bp++ = '}'; 01627 } 01628 *bp = '\0'; 01629 skip_nul_locate = true; 01630 ACE_Log_Msg::msg_off_ = osave; 01631 break; 01632 } 01633 01634 case 'S': // format the string for with this signal number. 01635 { 01636 const int sig = va_arg (argp, int); 01637 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01638 if (can_check) 01639 this_len = ACE_OS::snprintf 01640 (bp, bspace, format, ACE_OS::strsignal(sig)); 01641 else 01642 this_len = ACE_OS::sprintf 01643 (bp, format, ACE_OS::strsignal(sig)); 01644 ACE_UPDATE_COUNT (bspace, this_len); 01645 break; 01646 } 01647 01648 case 'D': // Format the timestamp in format: 01649 // Weekday Month day year hour:minute:sec.usec 01650 { 01651 ACE_TCHAR day_and_time[35]; 01652 ACE::timestamp (day_and_time, 01653 sizeof day_and_time / sizeof (ACE_TCHAR)); 01654 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01655 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01656 #else 01657 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01658 #endif 01659 if (can_check) 01660 this_len = ACE_OS::snprintf 01661 (bp, bspace, format, day_and_time); 01662 else 01663 this_len = ACE_OS::sprintf (bp, format, day_and_time); 01664 ACE_UPDATE_COUNT (bspace, this_len); 01665 break; 01666 } 01667 01668 case 'T': // Format the timestamp in 01669 // hour:minute:sec:usec format. 01670 { 01671 ACE_TCHAR day_and_time[35]; 01672 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01673 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01674 #else 01675 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01676 #endif 01677 if (can_check) 01678 this_len = ACE_OS::snprintf 01679 (bp, bspace, format, 01680 ACE::timestamp (day_and_time, sizeof day_and_time / sizeof (ACE_TCHAR))); 01681 else 01682 this_len = ACE_OS::sprintf 01683 (bp, format, ACE::timestamp (day_and_time, 01684 sizeof day_and_time / sizeof (ACE_TCHAR))); 01685 ACE_UPDATE_COUNT (bspace, this_len); 01686 break; 01687 } 01688 01689 case 't': // Format thread id. 01690 #if defined (ACE_WIN32) 01691 ACE_OS::strcpy (fp, ACE_TEXT ("u")); 01692 if (can_check) 01693 this_len = ACE_OS::snprintf 01694 (bp, bspace, format, 01695 static_cast<unsigned> (ACE_Thread::self ())); 01696 else 01697 this_len = 01698 ACE_OS::sprintf (bp, 01699 format, 01700 static_cast <unsigned> (ACE_Thread::self ())); 01701 #elif defined (DIGITAL_UNIX) 01702 ACE_OS::strcpy (fp, ACE_TEXT ("u")); 01703 { 01704 int id = 01705 # if defined (ACE_HAS_THREADS) 01706 pthread_getselfseq_np (); 01707 # else 01708 ACE_Thread::self (); 01709 # endif /* ACE_HAS_THREADS */ 01710 01711 if (can_check) 01712 this_len = ACE_OS::snprintf (bp, bspace, format, id); 01713 else 01714 this_len = ACE_OS::sprintf (bp, format, id); 01715 } 01716 #else 01717 ACE_hthread_t t_id; 01718 ACE_Thread::self (t_id); 01719 01720 # if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS) 01721 // MVS's pthread_t is a struct... yuck. So use the ACE 5.0 01722 // code for it. 01723 ACE_OS::strcpy (fp, ACE_TEXT ("u")); 01724 if (can_check) 01725 this_len = ACE_OS::snprintf (bp, bspace, format, t_id); 01726 else 01727 this_len = ACE_OS::sprintf (bp, format, t_id); 01728 # else 01729 // Yes, this is an ugly C-style cast, but the correct 01730 // C++ cast is different depending on whether the t_id 01731 // is an integral type or a pointer type. FreeBSD uses 01732 // a pointer type, but doesn't have a _np function to 01733 // get an integral type, like the OSes above. 01734 ACE_OS::strcpy (fp, ACE_TEXT ("lu")); 01735 if (can_check) 01736 this_len = ACE_OS::snprintf 01737 (bp, bspace, format, (unsigned long)t_id); 01738 else 01739 this_len = ACE_OS::sprintf 01740 (bp, format, (unsigned long)t_id); 01741 # endif /* ACE_MWS || ACE_TANDEM_T1248_PTHREADS */ 01742 01743 #endif /* ACE_WIN32 */ 01744 ACE_UPDATE_COUNT (bspace, this_len); 01745 break; 01746 01747 case 's': // String 01748 { 01749 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01750 wchar_t *str = va_arg (argp, wchar_t *); 01751 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01752 #else /* ACE_WIN32 && ACE_USES_WCHAR */ 01753 ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *); 01754 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01755 #endif /* ACE_WIN32 && ACE_USES_WCHAR */ 01756 if (can_check) 01757 this_len = ACE_OS::snprintf 01758 (bp, bspace, format, str ? str : ACE_TEXT ("(null)")); 01759 else 01760 this_len = ACE_OS::sprintf 01761 (bp, format, str ? str : ACE_TEXT ("(null)")); 01762 ACE_UPDATE_COUNT (bspace, this_len); 01763 } 01764 break; 01765 01766 case 'C': // Narrow-char string 01767 { 01768 char *cstr = va_arg (argp, char *); 01769 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01770 ACE_OS::strcpy (fp, ACE_TEXT ("S")); 01771 #else /* ACE_WIN32 && ACE_USES_WCHAR */ 01772 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01773 #endif /* ACE_WIN32 && ACE_USES_WCHAR */ 01774 if (can_check) 01775 this_len = ACE_OS::snprintf 01776 (bp, bspace, format, cstr ? cstr : "(null)"); 01777 else 01778 this_len = ACE_OS::sprintf 01779 (bp, format, cstr ? cstr : "(null)"); 01780 ACE_UPDATE_COUNT (bspace, this_len); 01781 } 01782 break; 01783 01784 case 'W': 01785 { 01786 #if defined (ACE_HAS_WCHAR) 01787 wchar_t *wchar_str = va_arg (argp, wchar_t *); 01788 # if defined (HPUX) 01789 ACE_OS::strcpy (fp, ACE_TEXT ("S")); 01790 # elif defined (ACE_WIN32) 01791 # if defined (ACE_USES_WCHAR) 01792 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01793 # else /* ACE_USES_WCHAR */ 01794 ACE_OS::strcpy (fp, ACE_TEXT ("S")); 01795 # endif /* ACE_USES_WCHAR */ 01796 # else 01797 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01798 # endif /* HPUX */ 01799 if (can_check) 01800 this_len = ACE_OS::snprintf 01801 (bp, bspace, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)")); 01802 else 01803 this_len = ACE_OS::sprintf 01804 (bp, format, wchar_str ? wchar_str : ACE_TEXT_WIDE("(null)")); 01805 #endif /* ACE_HAS_WCHAR */ 01806 ACE_UPDATE_COUNT (bspace, this_len); 01807 } 01808 break; 01809 01810 case 'w': // Wide character 01811 #if defined (ACE_WIN32) 01812 # if defined (ACE_USES_WCHAR) 01813 ACE_OS::strcpy (fp, ACE_TEXT ("c")); 01814 # else /* ACE_USES_WCHAR */ 01815 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01816 # endif /* ACE_USES_WCHAR */ 01817 if (can_check) 01818 this_len = ACE_OS::snprintf 01819 (bp, bspace, format, va_arg (argp, int)); 01820 else 01821 this_len = ACE_OS::sprintf 01822 (bp, format, va_arg (argp, int)); 01823 #elif defined (ACE_USES_WCHAR) 01824 # if defined (HPUX) 01825 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01826 # else 01827 ACE_OS::strcpy (fp, ACE_TEXT ("lc")); 01828 # endif /* HPUX */ 01829 if (can_check) 01830 this_len = ACE_OS::snprintf 01831 (bp, bspace, format, va_arg (argp, wint_t)); 01832 else 01833 this_len = ACE_OS::sprintf 01834 (bp, format, va_arg (argp, wint_t)); 01835 #else /* ACE_WIN32 */ 01836 ACE_OS::strcpy (fp, ACE_TEXT ("u")); 01837 if (can_check) 01838 this_len = ACE_OS::snprintf 01839 (bp, bspace, format, va_arg (argp, int)); 01840 else 01841 this_len = ACE_OS::sprintf 01842 (bp, format, va_arg (argp, int)); 01843 #endif /* ACE_WIN32 */ 01844 ACE_UPDATE_COUNT (bspace, this_len); 01845 break; 01846 01847 case 'z': // ACE_OS::WChar character 01848 { 01849 // On some platforms sizeof (wchar_t) can be 2 01850 // on the others 4 ... 01851 wchar_t wtchar = 01852 static_cast<wchar_t> (va_arg (argp, int)); 01853 #if defined (ACE_WIN32) 01854 # if defined (ACE_USES_WCHAR) 01855 ACE_OS::strcpy (fp, ACE_TEXT ("c")); 01856 # else /* ACE_USES_WCHAR */ 01857 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01858 # endif /* ACE_USES_WCHAR */ 01859 #elif defined (ACE_USES_WCHAR) 01860 # if defined (HPUX) 01861 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01862 # else 01863 ACE_OS::strcpy (fp, ACE_TEXT ("lc")); 01864 # endif /* HPUX */ 01865 #else /* ACE_WIN32 */ 01866 ACE_OS::strcpy (fp, ACE_TEXT ("u")); 01867 #endif /* ACE_WIN32 */ 01868 if (can_check) 01869 this_len = ACE_OS::snprintf (bp, bspace, format, wtchar); 01870 else 01871 this_len = ACE_OS::sprintf (bp, format, wtchar); 01872 ACE_UPDATE_COUNT (bspace, this_len); 01873 break; 01874 } 01875 01876 case 'Z': // ACE_OS::WChar character string 01877 { 01878 ACE_OS::WChar *wchar_str = va_arg (argp, ACE_OS::WChar*); 01879 if (wchar_str == 0) 01880 break; 01881 01882 wchar_t *wchar_t_str = 0; 01883 if (sizeof (ACE_OS::WChar) != sizeof (wchar_t)) 01884 { 01885 size_t len = ACE_OS::wslen (wchar_str) + 1; 01886 ACE_NEW_NORETURN(wchar_t_str, wchar_t[len]); 01887 if (wchar_t_str == 0) 01888 break; 01889 01890 for (size_t i = 0; i < len; ++i) 01891 { 01892 wchar_t_str[i] = wchar_str[i]; 01893 } 01894 } 01895 01896 if (wchar_t_str == 0) 01897 { 01898 wchar_t_str = reinterpret_cast<wchar_t*> (wchar_str); 01899 } 01900 #if defined (ACE_WIN32) 01901 # if defined (ACE_USES_WCHAR) 01902 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 01903 # else /* ACE_USES_WCHAR */ 01904 ACE_OS::strcpy (fp, ACE_TEXT ("S")); 01905 # endif /* ACE_USES_WCHAR */ 01906 #elif defined (ACE_HAS_WCHAR) 01907 # if defined (HPUX) 01908 ACE_OS::strcpy (fp, ACE_TEXT ("S")); 01909 # else 01910 ACE_OS::strcpy (fp, ACE_TEXT ("ls")); 01911 # endif /* HPUX */ 01912 #endif /* ACE_WIN32 / ACE_HAS_WCHAR */ 01913 if (can_check) 01914 this_len = ACE_OS::snprintf 01915 (bp, bspace, format, wchar_t_str); 01916 else 01917 this_len = ACE_OS::sprintf (bp, format, wchar_t_str); 01918 if(sizeof(ACE_OS::WChar) != sizeof(wchar_t)) 01919 { 01920 delete [] wchar_t_str; 01921 } 01922 ACE_UPDATE_COUNT (bspace, this_len); 01923 break; 01924 } 01925 01926 case 'c': 01927 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 01928 ACE_OS::strcpy (fp, ACE_TEXT ("C")); 01929 #else 01930 ACE_OS::strcpy (fp, ACE_TEXT ("c")); 01931 #endif /* ACE_WIN32 && ACE_USES_WCHAR */ 01932 if (can_check) 01933 this_len = ACE_OS::snprintf 01934 (bp, bspace, format, va_arg (argp, int)); 01935 else 01936 this_len = ACE_OS::sprintf 01937 (bp, format, va_arg (argp, int)); 01938 ACE_UPDATE_COUNT (bspace, this_len); 01939 break; 01940 01941 case 'd': case 'i': case 'o': 01942 case 'u': case 'x': case 'X': 01943 fp[0] = *format_str; 01944 fp[1] = '\0'; 01945 if (can_check) 01946 this_len = ACE_OS::snprintf 01947 (bp, bspace, format, va_arg (argp, int)); 01948 else 01949 this_len = ACE_OS::sprintf 01950 (bp, format, va_arg (argp, int)); 01951 ACE_UPDATE_COUNT (bspace, this_len); 01952 break; 01953 01954 case 'F': case 'f': case 'e': case 'E': 01955 case 'g': case 'G': 01956 fp[0] = *format_str; 01957 fp[1] = '\0'; 01958 if (can_check) 01959 this_len = ACE_OS::snprintf 01960 (bp, bspace, format, va_arg (argp, double)); 01961 else 01962 this_len = ACE_OS::sprintf 01963 (bp, format, va_arg (argp, double)); 01964 ACE_UPDATE_COUNT (bspace, this_len); 01965 break; 01966 01967 case 'Q': 01968 #if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) 01969 { 01970 // This relies on the ACE_U_LongLong storage layout. 01971 ACE_UINT32 hi = va_arg (argp, ACE_UINT32); 01972 ACE_UINT32 lo = va_arg (argp, ACE_UINT32); 01973 if (hi > 0) 01974 this_len = ACE_OS::sprintf (bp, 01975 "0x%lx%0*lx", 01976 hi, 01977 2 * sizeof lo, 01978 lo); 01979 else 01980 this_len = ACE_OS::sprintf (bp, "0x%lx", lo); 01981 } 01982 #else /* ! ACE_LACKS_LONGLONG_T */ 01983 { 01984 const ACE_TCHAR *fmt = ACE_UINT64_FORMAT_SPECIFIER; 01985 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % 01986 if (can_check) 01987 this_len = ACE_OS::snprintf (bp, bspace, 01988 format, 01989 va_arg (argp, ACE_UINT64)); 01990 else 01991 this_len = ACE_OS::sprintf (bp, 01992 format, 01993 va_arg (argp, ACE_UINT64)); 01994 } 01995 #endif /* ! ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ 01996 ACE_UPDATE_COUNT (bspace, this_len); 01997 break; 01998 01999 case 'q': 02000 #if defined (ACE_LACKS_LONGLONG_T) 02001 // No implementation available yet, no ACE_INT64 emulation 02002 // available yet 02003 #else /* ! ACE_LACKS_LONGLONG_T */ 02004 { 02005 const ACE_TCHAR *fmt = ACE_INT64_FORMAT_SPECIFIER; 02006 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % 02007 if (can_check) 02008 this_len = ACE_OS::snprintf (bp, bspace, 02009 format, 02010 va_arg (argp, ACE_INT64)); 02011 else 02012 this_len = ACE_OS::sprintf (bp, 02013 format, 02014 va_arg (argp, ACE_INT64)); 02015 } 02016 #endif /* ! ACE_LACKS_LONGLONG_T */ 02017 ACE_UPDATE_COUNT (bspace, this_len); 02018 break; 02019 02020 case 'b': 02021 { 02022 const ACE_TCHAR *fmt = ACE_SSIZE_T_FORMAT_SPECIFIER; 02023 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % 02024 } 02025 if (can_check) 02026 this_len = ACE_OS::snprintf (bp, bspace, 02027 format, 02028 va_arg (argp, ssize_t)); 02029 else 02030 this_len = ACE_OS::sprintf (bp, 02031 format, 02032 va_arg (argp, ssize_t)); 02033 ACE_UPDATE_COUNT (bspace, this_len); 02034 break; 02035 02036 case 'B': 02037 { 02038 const ACE_TCHAR *fmt = ACE_SIZE_T_FORMAT_SPECIFIER; 02039 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % 02040 } 02041 if (can_check) 02042 this_len = ACE_OS::snprintf (bp, bspace, 02043 format, 02044 va_arg (argp, size_t)); 02045 else 02046 this_len = ACE_OS::sprintf (bp, 02047 format, 02048 va_arg (argp, size_t)); 02049 ACE_UPDATE_COUNT (bspace, this_len); 02050 break; 02051 02052 case ':': 02053 { 02054 // Assume a 32 bit time_t and change if needed. 02055 const ACE_TCHAR *fmt = ACE_TEXT ("%d"); 02056 if (sizeof (time_t) == 8) 02057 fmt = ACE_INT64_FORMAT_SPECIFIER; 02058 02059 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading % 02060 } 02061 if (can_check) 02062 this_len = ACE_OS::snprintf (bp, bspace, 02063 format, 02064 va_arg (argp, time_t)); 02065 else 02066 this_len = ACE_OS::sprintf (bp, 02067 format, 02068 va_arg (argp, time_t)); 02069 ACE_UPDATE_COUNT (bspace, this_len); 02070 break; 02071 02072 case '@': 02073 ACE_OS::strcpy (fp, ACE_TEXT ("p")); 02074 if (can_check) 02075 this_len = ACE_OS::snprintf 02076 (bp, bspace, format, va_arg (argp, void*)); 02077 else 02078 this_len = ACE_OS::sprintf 02079 (bp, format, va_arg (argp, void*)); 02080 ACE_UPDATE_COUNT (bspace, this_len); 02081 break; 02082 02083 case '?': 02084 // Stack trace up to this point 02085 { 02086 // skip the frame that we're currently in 02087 ACE_Stack_Trace t(2); 02088 ACE_OS::strcpy (fp, ACE_TEXT ("s")); 02089 if (can_check) 02090 this_len = ACE_OS::snprintf 02091 (bp, bspace, format, t.c_str ()); 02092 else 02093 this_len = ACE_OS::sprintf 02094 (bp, format, t.c_str ()); 02095 ACE_UPDATE_COUNT (bspace, this_len); 02096 break; 02097 } 02098 02099 02100 default: 02101 // So, it's not a legit format specifier after all... 02102 // Copy from the original % to where we are now, then 02103 // continue with whatever comes next. 02104 while (start_format != format_str && bspace > 0) 02105 { 02106 *bp++ = *start_format++; 02107 --bspace; 02108 } 02109 if (bspace > 0) 02110 { 02111 *bp++ = *format_str; 02112 --bspace; 02113 } 02114 break; 02115 } 02116 02117 // Bump to the next char in the caller's format_str 02118 ++format_str; 02119 } 02120 02121 if (!skip_nul_locate) 02122 while (*bp != '\0') // Locate end of bp. 02123 ++bp; 02124 } 02125 } 02126 02127 *bp = '\0'; // Terminate bp, but don't auto-increment this! 02128 02129 ssize_t result = 0; 02130 02131 // Check that memory was not corrupted, if it corrupted we can't log anything 02132 // anymore because all our members could be corrupted. 02133 if (bp >= (this->msg_ + ACE_MAXLOGMSGLEN+1)) 02134 { 02135 abort_prog = true; 02136 ACE_OS::fprintf (stderr, 02137 "The following logged message is too long!\n"); 02138 } 02139 else 02140 { 02141 // Copy the message from thread-specific storage into the transfer 02142 // buffer (this can be optimized away by changing other code...). 02143 log_record.msg_data (this->msg ()); 02144 02145 // Write the <log_record> to the appropriate location. 02146 result = this->log (log_record, 02147 abort_prog); 02148 } 02149 02150 if (abort_prog) 02151 { 02152 // Since we are now calling abort instead of exit, this value is 02153 // not used. 02154 ACE_UNUSED_ARG (exit_value); 02155 02156 // *Always* print a message to stderr if we're aborting. We 02157 // don't use verbose, however, to avoid recursive aborts if 02158 // something is hosed. 02159 log_record.print (ACE_Log_Msg::local_host_, 0, stderr); 02160 ACE_OS::abort (); 02161 } 02162 02163 return result; 02164 }
| ssize_t ACE_Log_Msg::log | ( | ACE_Log_Priority | priority, | |
| const ACE_ANTI_TCHAR * | format, | |||
| ... | ||||
| ) |
| ssize_t ACE_Log_Msg::log | ( | ACE_Log_Priority | log_priority, | |
| const ACE_TCHAR * | format_str, | |||
| ... | ||||
| ) |
Format a message to the thread-safe ACE logging mechanism. Valid options (prefixed by '', as in printf format strings) include:
Valid Options (prefixed by '', as in printf format strings) include: 'A': print an ACE_timer_t value 'a': exit the program at this point (var-argument is the exit status!) 'b': print a ssize_t value 'B': print a size_t value 'c': print a character 'C': print a character string 'i', 'd': print a decimal number 'I', indent according to nesting depth 'e', 'E', 'f', 'F', 'g', 'G': print a double 'l', print line number where an error occurred. 'M': print the name of the priority of the message. 'm': Return the message corresponding to errno value, e.g., as done by <strerror> 'N': print file name where the error occurred. 'n': print the name of the program (or "<unknown>" if not set) 'o': print as an octal number 'P': format the current process id 'p': format the appropriate errno message from sys_errlist, e.g., as done by <perror> 'Q': print out the uint64 number 'q': print out the int64 number '@': print a void* pointer (in hexadecimal) 'r': call the function pointed to by the corresponding argument 'R': print return status 'S': print out the appropriate signal message corresponding to var-argument, e.g., as done by strsignal() 's': format a character string 'T': print timestamp in hour:minute:sec:usec format. 'D': print timestamp in month/day/year hour:minute:sec:usec format. 't': print thread id (1 if single-threaded) 'u': print as unsigned int 'x': print as a hex number 'X': print as a hex number 'w': print a wide character 'W': print out a wide character string. 'z': print an ACE_OS::WChar character 'Z': print an ACE_OS::WChar character string ':': print a time_t value as an integral number '': format a single percent sign, ''
Definition at line 934 of file Log_Msg.cpp.
00936 { 00937 ACE_TRACE ("ACE_Log_Msg::log"); 00938 00939 // Start of variable args section. 00940 va_list argp; 00941 00942 va_start (argp, format_str); 00943 00944 ssize_t const result = this->log (format_str, 00945 log_priority, 00946 argp); 00947 va_end (argp); 00948 00949 return result; 00950 }
| int ACE_Log_Msg::log_hexdump | ( | ACE_Log_Priority | log_priority, | |
| const char * | buffer, | |||
| size_t | size, | |||
| const ACE_TCHAR * | text = 0 | |||
| ) |
Method to log hex dump. This is useful for debugging. Calls log() to do the actual print, but formats first to make the chars printable.
Definition at line 2308 of file Log_Msg.cpp.
02312 { 02313 // Only print the message if <priority_mask_> hasn't been reset to 02314 // exclude this logging priority. 02315 if (this->log_priority_enabled (log_priority) == 0) 02316 return 0; 02317 02318 ACE_TCHAR* buf = 0; 02319 size_t const buf_sz = 02320 ACE_Log_Record::MAXLOGMSGLEN - ACE_Log_Record::VERBOSE_LEN - 58; 02321 ACE_NEW_RETURN (buf, ACE_TCHAR[buf_sz], -1); 02322 02323 ACE_TCHAR *msg_buf = 0; 02324 const size_t text_sz = text ? ACE_OS::strlen(text) : 0; 02325 ACE_NEW_RETURN (msg_buf, 02326 ACE_TCHAR[text_sz + 58], 02327 -1); 02328 02329 buf[0] = 0; // in case size = 0 02330 02331 size_t const len = ACE::format_hexdump 02332 (buffer, size, buf, buf_sz / sizeof (ACE_TCHAR) - text_sz); 02333 02334 int sz = 0; 02335 02336 if (text) 02337 sz = ACE_OS::sprintf (msg_buf, 02338 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) 02339 ACE_TEXT ("%ls - "), 02340 #else 02341 ACE_TEXT ("%s - "), 02342 #endif 02343 text); 02344 02345 sz += ACE_OS::sprintf (msg_buf + sz, 02346 ACE_TEXT ("HEXDUMP ") 02347 ACE_SIZE_T_FORMAT_SPECIFIER 02348 ACE_TEXT (" bytes"), 02349 size); 02350 02351 if (len < size) 02352 ACE_OS::sprintf (msg_buf + sz, 02353 ACE_TEXT (" (showing first ") 02354 ACE_SIZE_T_FORMAT_SPECIFIER 02355 ACE_TEXT (" bytes)"), 02356 len); 02357 02358 // Now print out the formatted buffer. 02359 this->log (log_priority, 02360 ACE_TEXT ("%s\n%s"), 02361 msg_buf, 02362 buf); 02363 02364 delete [] msg_buf; 02365 delete [] buf; 02366 return 0; 02367 }
| int ACE_Log_Msg::log_priority_enabled | ( | ACE_Log_Priority | log_priority, | |
| const wchar_t * | , | |||
| ... | ||||
| ) |
Return true if the requested priority is enabled.
| int ACE_Log_Msg::log_priority_enabled | ( | ACE_Log_Priority | log_priority, | |
| const char * | , | |||
| ... | ||||
| ) |
Return true if the requested priority is enabled.
Definition at line 2553 of file Log_Msg.cpp.
02556 { 02557 return this->log_priority_enabled (log_priority); 02558 }
| int ACE_Log_Msg::log_priority_enabled | ( | ACE_Log_Priority | log_priority | ) |
Return true if the requested priority is enabled.
Definition at line 21 of file Log_Msg.inl.
00022 { 00023 return ACE_BIT_ENABLED (this->priority_mask_ | 00024 ACE_Log_Msg::process_priority_mask_, 00025 log_priority); 00026 }
| const ACE_TCHAR * ACE_Log_Msg::msg | ( | void | ) |
Get the message that describes what type of error occurred.
Definition at line 172 of file Log_Msg.inl.
00173 { 00174 return this->msg_ + ACE_Log_Msg::msg_off_; 00175 }
| void ACE_Log_Msg::msg | ( | const ACE_TCHAR * | m | ) |
Set the message that describes what type of error occurred.
Definition at line 179 of file Log_Msg.inl.
00180 { 00181 ACE_OS::strsncpy (this->msg_, m, 00182 ((ACE_MAXLOGMSGLEN+1) / sizeof (ACE_TCHAR))); 00183 }
| ACE_Log_Msg_Backend * ACE_Log_Msg::msg_backend | ( | void | ) | [static] |
Definition at line 2496 of file Log_Msg.cpp.
02497 { 02498 ACE_TRACE ("ACE_Log_Msg::msg_backend"); 02499 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 02500 *ACE_Log_Msg_Manager::get_lock (), 0)); 02501 02502 return ACE_Log_Msg_Manager::custom_backend_; 02503 }
| ACE_Log_Msg_Backend * ACE_Log_Msg::msg_backend | ( | ACE_Log_Msg_Backend * | b | ) | [static] |
Set a new backend object and return the existing backend to allow "chaining". Note that as opposed to ACE_Log_Msg_Callback, ACE_Log_Msg_Backend is a per-process entity.
Definition at line 2484 of file Log_Msg.cpp.
02485 { 02486 ACE_TRACE ("ACE_Log_Msg::msg_backend"); 02487 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 02488 *ACE_Log_Msg_Manager::get_lock (), 0)); 02489 02490 ACE_Log_Msg_Backend *tmp = ACE_Log_Msg_Manager::custom_backend_; 02491 ACE_Log_Msg_Manager::custom_backend_ = b; 02492 return tmp; 02493 }
| ACE_Log_Msg_Callback * ACE_Log_Msg::msg_callback | ( | void | ) | const |
Definition at line 187 of file Log_Msg.inl.
00188 { 00189 return this->msg_callback_; 00190 }
| ACE_Log_Msg_Callback * ACE_Log_Msg::msg_callback | ( | ACE_Log_Msg_Callback * | c | ) |
Set a new callback object and return the existing callback to allow "chaining". Note that ACE_Log_Msg_Callback objects are not inherited when spawning a new thread, so you'll need to reset them in each thread.
Definition at line 194 of file Log_Msg.inl.
00195 { 00196 ACE_Log_Msg_Callback *old = this->msg_callback_; 00197 this->msg_callback_ = c; 00198 return old; 00199 }
| ACE_OSTREAM_TYPE * ACE_Log_Msg::msg_ostream | ( | void | ) | const |
Get the ostream that is used to print error messages.
Definition at line 203 of file Log_Msg.inl.
00204 { 00205 return this->ostream_; 00206 }
| void ACE_Log_Msg::msg_ostream | ( | ACE_OSTREAM_TYPE * | m, | |
| bool | delete_ostream | |||
| ) |
delete_stream == true, forces Log_Msg.h to delete the stream in its own ~dtor (assumes control of the stream) use only with proper ostream (eg: fstream), not (cout, cerr)
Definition at line 2506 of file Log_Msg.cpp.
02507 { 02508 if (this->ostream_ == m) 02509 { 02510 // Same stream, allow user to change the delete_ostream "flag" 02511 if (delete_ostream && !this->ostream_refcount_) 02512 { 02513 ACE_NEW (this->ostream_refcount_, Atomic_ULong (1)); 02514 } 02515 else if (!delete_ostream && this->ostream_refcount_) 02516 { 02517 if (--*this->ostream_refcount_ == 0) 02518 { 02519 delete this->ostream_refcount_; 02520 } 02521 this->ostream_refcount_ = 0; 02522 } 02523 // The other two cases are no-ops, the user has requested the same 02524 // state that's already present. 02525 return; 02526 } 02527 02528 this->cleanup_ostream (); 02529 02530 if (delete_ostream) 02531 { 02532 ACE_NEW (this->ostream_refcount_, Atomic_ULong (1)); 02533 } 02534 02535 this->ostream_ = m; 02536 }
| void ACE_Log_Msg::msg_ostream | ( | ACE_OSTREAM_TYPE * | m | ) |
Update the ostream without overwriting the delete_ostream_ flag.
Definition at line 210 of file Log_Msg.inl.
00211 { 00212 this->ostream_ = m; 00213 }
| int ACE_Log_Msg::op_status | ( | void | ) | const |
Get the result of the operation status (by convention, -1 means error).
Definition at line 37 of file Log_Msg.inl.
00038 { 00039 return this->status_; 00040 }
| void ACE_Log_Msg::op_status | ( | int | status | ) |
Set the result of the operation status (by convention, -1 means error).
Definition at line 30 of file Log_Msg.inl.
| int ACE_Log_Msg::open | ( | const ACE_TCHAR * | prog_name, | |
| u_long | options_flags = ACE_Log_Msg::STDERR, |
|||
| const ACE_TCHAR * | logger_key = 0 | |||
| ) |
Initialize the ACE logging facility.
Initialize the ACE logging facility. Supplies the program name that is available to each logging message call. Default arguments set up logging to STDERR only.
| prog_name | The name of the calling program. | |
| options_flags | A bitwise-or of options flags used to set the initial behavior and logging sink(s). (see the enum above for the valid values). | |
| logger_key | The name of ACE_FIFO rendezvous point where the local client logger daemon is listening for logging messages if the LOGGER bit is set in the flags argument. If the SYSLOG bit is set in flags, logger_key is the source/program name specified in the syslog facility (UNIX/Linux) or the Windows event log (Windows). In the SYSLOG case, if logger_key is 0, prog_name is used. |
Definition at line 768 of file Log_Msg.cpp.
00771 { 00772 ACE_TRACE ("ACE_Log_Msg::open"); 00773 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00774 *ACE_Log_Msg_Manager::get_lock (), -1)); 00775 00776 if (prog_name) 00777 { 00778 ACE_OS::free ((void *) ACE_Log_Msg::program_name_); 00779 00780 // Stop heap checking, block will be freed by the destructor. 00781 { 00782 ACE_NO_HEAP_CHECK; 00783 00784 ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, 00785 ACE_OS::strdup (prog_name), 00786 -1); 00787 } 00788 } 00789 else if (ACE_Log_Msg::program_name_ == 0) 00790 { 00791 // Stop heap checking, block will be freed by the destructor. 00792 ACE_NO_HEAP_CHECK; 00793 ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_, 00794 ACE_OS::strdup (ACE_TEXT ("<unknown>")), 00795 -1); 00796 } 00797 00798 int status = 0; 00799 00800 // Be sure that there is a message_queue_, with multiple threads. 00801 ACE_MT (ACE_Log_Msg_Manager::init_backend (&flags)); 00802 00803 // Always close the current handle before doing anything else. 00804 if (ACE_Log_Msg_Manager::log_backend_ != 0) 00805 ACE_Log_Msg_Manager::log_backend_->reset (); 00806 00807 if (ACE_Log_Msg_Manager::custom_backend_ != 0) 00808 ACE_Log_Msg_Manager::custom_backend_->reset (); 00809 00810 // Note that if we fail to open the message queue the default action 00811 // is to use stderr (set via static initialization in the 00812 // Log_Msg.cpp file). 00813 00814 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER) 00815 || ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG)) 00816 { 00817 // The SYSLOG backends (both NT and UNIX) can get along fine 00818 // without the logger_key - they will default to prog_name if 00819 // logger key is 0. 00820 if (logger_key == 0 && ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)) 00821 status = -1; 00822 else 00823 status = ACE_Log_Msg_Manager::log_backend_->open (logger_key); 00824 00825 if (status == -1) 00826 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); 00827 else 00828 { 00829 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)) 00830 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER); 00831 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG)) 00832 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG); 00833 } 00834 } 00835 else if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) 00836 || ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG)) 00837 { 00838 // If we are closing down logger, redirect logging to stderr. 00839 ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER); 00840 ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG); 00841 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR); 00842 } 00843 00844 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM)) 00845 { 00846 status = 00847 ACE_Log_Msg_Manager::custom_backend_->open (logger_key); 00848 00849 if (status != -1) 00850 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM); 00851 } 00852 00853 // Remember, ACE_Log_Msg::STDERR bit is on by default... 00854 if (status != -1 00855 && ACE_BIT_ENABLED (flags, 00856 ACE_Log_Msg::STDERR) == 0) 00857 ACE_CLR_BITS (ACE_Log_Msg::flags_, 00858 ACE_Log_Msg::STDERR); 00859 00860 // VERBOSE takes precedence over VERBOSE_LITE... 00861 if (ACE_BIT_ENABLED (flags, 00862 ACE_Log_Msg::VERBOSE_LITE)) 00863 ACE_SET_BITS (ACE_Log_Msg::flags_, 00864 ACE_Log_Msg::VERBOSE_LITE); 00865 else if (ACE_BIT_ENABLED (flags, 00866 ACE_Log_Msg::VERBOSE)) 00867 ACE_SET_BITS (ACE_Log_Msg::flags_, 00868 ACE_Log_Msg::VERBOSE); 00869 00870 if (ACE_BIT_ENABLED (flags, 00871 ACE_Log_Msg::OSTREAM)) 00872 { 00873 ACE_SET_BITS (ACE_Log_Msg::flags_, 00874 ACE_Log_Msg::OSTREAM); 00875 // Only set this to cerr if it hasn't already been set. 00876 if (this->msg_ostream () == 0) 00877 this->msg_ostream (ACE_DEFAULT_LOG_STREAM); 00878 } 00879 00880 if (ACE_BIT_ENABLED (flags, 00881 ACE_Log_Msg::MSG_CALLBACK)) 00882 ACE_SET_BITS (ACE_Log_Msg::flags_, 00883 ACE_Log_Msg::MSG_CALLBACK); 00884 00885 if (ACE_BIT_ENABLED (flags, 00886 ACE_Log_Msg::SILENT)) 00887 ACE_SET_BITS (ACE_Log_Msg::flags_, 00888 ACE_Log_Msg::SILENT); 00889 00890 return status; 00891 }
| ACE_Log_Msg& ACE_Log_Msg::operator= | ( | const ACE_Log_Msg & | ) | [private] |
| u_long ACE_Log_Msg::priority_mask | ( | u_long | n_mask, | |
| MASK_TYPE | mask_type = THREAD | |||
| ) |
Set the ACE_Log_Priority mask, returns original mask.
Definition at line 611 of file Log_Msg.cpp.
00612 { 00613 u_long o_mask; 00614 00615 if (mask_type == THREAD) 00616 { 00617 o_mask = this->priority_mask_; 00618 this->priority_mask_ = n_mask; 00619 } 00620 else 00621 { 00622 o_mask = ACE_Log_Msg::process_priority_mask_; 00623 ACE_Log_Msg::process_priority_mask_ = n_mask; 00624 } 00625 00626 return o_mask; 00627 }
| u_long ACE_Log_Msg::priority_mask | ( | MASK_TYPE | mask_type = THREAD |
) |
Get the current ACE_Log_Priority mask.
Definition at line 12 of file Log_Msg.inl.
00013 { 00014 return mask_type == THREAD 00015 ? this->priority_mask_ 00016 : ACE_Log_Msg::process_priority_mask_; 00017 }
| const ACE_TCHAR * ACE_Log_Msg::program_name | ( | void | ) | [static] |
Returns the current program name used for logging.
Definition at line 434 of file Log_Msg.cpp.
00435 { 00436 return ACE_Log_Msg::program_name_; 00437 }
| int ACE_Log_Msg::release | ( | void | ) |
Release the internal lock.
Definition at line 630 of file Log_Msg.cpp.
00631 { 00632 ACE_TRACE ("ACE_Log_Msg::release"); 00633 00634 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00635 return ACE_Log_Msg_Manager::get_lock ()->release (); 00636 #else /* ! ACE_MT_SAFE */ 00637 return 0; 00638 #endif /* ! ACE_MT_SAFE */ 00639 }
| bool ACE_Log_Msg::restart | ( | void | ) | const |
Get the field that indicates whether interrupted calls should be restarted.
Definition at line 51 of file Log_Msg.inl.
00052 { 00053 return this->restart_; 00054 }
| void ACE_Log_Msg::restart | ( | bool | r | ) |
Set the field that indicates whether interrupted calls should be restarted.
Definition at line 44 of file Log_Msg.inl.
00045 { 00046 this->restart_ = r; 00047 }
| ACE_SEH_EXCEPT_HANDLER ACE_Log_Msg::seh_except_handler | ( | ACE_SEH_EXCEPT_HANDLER | ) |
Set TSS exception handler.
| ACE_SEH_EXCEPT_HANDLER ACE_Log_Msg::seh_except_handler | ( | void | ) |
Get TSS exception handler.
| ACE_SEH_EXCEPT_HANDLER ACE_Log_Msg::seh_except_selector | ( | ACE_SEH_EXCEPT_HANDLER | ) |
Set TSS exception action.
| ACE_SEH_EXCEPT_HANDLER ACE_Log_Msg::seh_except_selector | ( | void | ) |
Get TSS exception action.
| void ACE_Log_Msg::set | ( | const char * | file, | |
| int | line, | |||
| int | op_status = -1, |
|||
| int | errnum = 0, |
|||
| bool | restart = true, |
|||
| ACE_OSTREAM_TYPE * | os = 0, |
|||
| ACE_Log_Msg_Callback * | c = 0 | |||
| ) |
Set the line number, file name, operational status, error number, restart flag, ostream, and the callback object. This combines all the other set methods into a single method.
Definition at line 2370 of file Log_Msg.cpp.
| void ACE_Log_Msg::set_flags | ( | u_long | f | ) |
Enable the bits in the logger's options flags.
Definition at line 580 of file Log_Msg.cpp.
00581 { 00582 ACE_TRACE ("ACE_Log_Msg::set_flags"); 00583 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00584 *ACE_Log_Msg_Manager::get_lock ())); 00585 00586 ACE_SET_BITS (ACE_Log_Msg::flags_, flgs); 00587 }
| void ACE_Log_Msg::start_tracing | ( | void | ) |
Start tracing status on a per-thread basis...
Enable the tracing facility on a per-thread basis.
Definition at line 136 of file Log_Msg.inl.
00137 { 00138 this->tracing_enabled_ = true; 00139 }
| void ACE_Log_Msg::stop_tracing | ( | void | ) |
Stop tracing status on a per-thread basis...
Disable the tracing facility on a per-thread basis.
Definition at line 144 of file Log_Msg.inl.
00145 { 00146 this->tracing_enabled_ = false; 00147 }
| void ACE_Log_Msg::sync | ( | const ACE_TCHAR * | program_name | ) |
Call after doing a fork() to resynchronize the process id and program_name_ variables.
Definition at line 544 of file Log_Msg.cpp.
00545 { 00546 ACE_TRACE ("ACE_Log_Msg::sync"); 00547 00548 if (prog_name) 00549 { 00550 // Must free if already allocated!!! 00551 ACE_OS::free ((void *) ACE_Log_Msg::program_name_); 00552 00553 // Stop heap checking, block will be freed by the destructor when 00554 // the last ACE_Log_Msg instance is deleted. 00555 // Heap checking state will be restored when the block is left. 00556 { 00557 ACE_NO_HEAP_CHECK; 00558 00559 ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name); 00560 } 00561 } 00562 00563 ACE_Log_Msg::pid_ = ACE_OS::getpid (); 00564 ACE_Log_Msg::msg_off_ = 0; 00565 }
| void ACE_Log_Msg::sync_hook | ( | const ACE_TCHAR * | prg_name | ) | [static, private] |
Decouple the OS layer from the ACE_Log_Msg layer.
Definition at line 530 of file Log_Msg.cpp.
| void ACE_Log_Msg::thr_desc | ( | ACE_Thread_Descriptor * | td | ) |
Set the TSS thread descriptor. This method will call td->acquire_release to block execution until this call return.
Definition at line 2449 of file Log_Msg.cpp.
02450 { 02451 this->thr_desc_ = td; 02452 02453 if (td != 0) 02454 td->acquire_release (); 02455 }
| ACE_Thread_Descriptor * ACE_Log_Msg::thr_desc | ( | void | ) | const |
Get the TSS thread descriptor.
Definition at line 128 of file Log_Msg.inl.
00129 { 00130 return this->thr_desc_; 00131 }
| ACE_OS_Thread_Descriptor * ACE_Log_Msg::thr_desc_hook | ( | void | ) | [static, private] |
Return the TSS singleton thread descriptor.
Definition at line 536 of file Log_Msg.cpp.
| void ACE_Log_Msg::trace_active | ( | bool | value | ) |
Set trace active status.
Definition at line 121 of file Log_Msg.inl.
00122 { 00123 this->trace_active_ = value; 00124 }
| bool ACE_Log_Msg::trace_active | ( | void | ) | const |
Get trace active status.
Definition at line 114 of file Log_Msg.inl.
00115 { 00116 return this->trace_active_; 00117 }
| void ACE_Log_Msg::trace_depth | ( | int | depth | ) |
Set trace depth.
Definition at line 107 of file Log_Msg.inl.
00108 { 00109 this->trace_depth_ = depth; 00110 }
| int ACE_Log_Msg::trace_depth | ( | void | ) | const |
Get trace depth.
Definition at line 100 of file Log_Msg.inl.
00101 { 00102 return this->trace_depth_; 00103 }
| bool ACE_Log_Msg::tracing_enabled | ( | void | ) | const |
Query tracing status on a per-thread basis...
Definition at line 151 of file Log_Msg.inl.
00152 { 00153 return this->tracing_enabled_; 00154 }
struct { ... } ACE_Log_Msg::conditional_values_ [private] |
Anonymous struct since there will only be one instance. This struct keeps information stored away in case we actually end up calling log() if the log priority is correct.
u_long ACE_Log_Msg::default_priority_mask_ = 0 [static, private] |
int ACE_Log_Msg::errnum_ [private] |
| const char* ACE_Log_Msg::file_ |
char ACE_Log_Msg::file_[MAXPATHLEN+1] [private] |
u_long ACE_Log_Msg::flags_ = ACE_Log_Msg::STDERR [static, private] |
int ACE_Log_Msg::instance_count_ = 0 [static, private] |
Number of existing ACE_Log_Msg instances; when 0, delete program/host names
Instance count for Log_Msg - used to know when dynamically allocated storage (program name and host name) can be safely deleted.
| bool ACE_Log_Msg::is_set_ |
bool ACE_Log_Msg::key_created_ [static, private] |
int ACE_Log_Msg::linenum_ [private] |
const ACE_TCHAR * ACE_Log_Msg::local_host_ = 0 [static, private] |
ACE_TCHAR* ACE_Log_Msg::msg_ [private] |
ACE_Log_Msg_Callback* ACE_Log_Msg::msg_callback_ [private] |
ptrdiff_t ACE_Log_Msg::msg_off_ = 0 [static, private] |
ACE_OSTREAM_TYPE* ACE_Log_Msg::ostream_ [private] |
Atomic_ULong* ACE_Log_Msg::ostream_refcount_ [private] |
pid_t ACE_Log_Msg::pid_ = -2 [static, private] |
u_long ACE_Log_Msg::priority_mask_ [private] |
u_long ACE_Log_Msg::process_priority_mask_ [static, private] |
LM_SHUTDOWN | LM_TRACE | LM_DEBUG | LM_INFO | LM_NOTICE | LM_WARNING | LM_STARTUP | LM_ERROR | LM_CRITICAL | LM_ALERT | LM_EMERGENCY
Keeps track of all the per-process ACE_Log_Priority values that are currently enabled. Default is for all logging priorities to be enabled.
Default per-process priority mask By default, all priorities are enabled.
const ACE_TCHAR * ACE_Log_Msg::program_name_ = 0 [static, private] |
bool ACE_Log_Msg::restart_ [private] |
int ACE_Log_Msg::status_ [private] |
ACE_Thread_Descriptor* ACE_Log_Msg::thr_desc_ [private] |
If we're running in the context of an ACE_Thread_Manager this will point to the thread descriptor adapter which holds the thread descriptor of the thread. This can be used to repidly access all thread data kept in ACE_Thread_Descriptor.
int ACE_Log_Msg::timestamp_ [private] |
bool ACE_Log_Msg::trace_active_ [private] |
int ACE_Log_Msg::trace_depth_ [private] |
bool ACE_Log_Msg::tracing_enabled_ [private] |
1.6.1