#include <Log_Msg.h>
Collaboration diagram for ACE_Log_Msg:

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) |
| void | errnum (int) |
| int | errnum (void) |
| void | linenum (int) |
| Set the line number where an error occurred. | |
| int | linenum (void) |
| 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 (int) |
| int | restart (void) |
| void | msg_ostream (ACE_OSTREAM_TYPE *) |
| Update the ostream without overwriting the delete_ostream_ flag. | |
| void | msg_ostream (ACE_OSTREAM_TYPE *, int 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) |
| Get trace depth. | |
| void | trace_depth (int) |
| Set trace depth. | |
| int | trace_active (void) |
| Set trace active status. | |
| void | trace_active (int value) |
| Get trace active status. | |
| ACE_Thread_Descriptor * | thr_desc (void) const |
| Get the TSS thread descriptor. | |
| void | thr_desc (ACE_Thread_Descriptor *td) |
| void | stop_tracing (void) |
| Stop tracing status on a per-thread basis... | |
| void | start_tracing (void) |
| Start tracing status on a per-thread basis... | |
| int | tracing_enabled (void) |
| 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. | |
| 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, int restart=1, 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 | |
lock
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 | |
| ACE_Log_Msg * | instance (void) |
| Returns a pointer to the Singleton. | |
| int | last_error_adapter (void) |
| Returns last error. | |
| int | exists (void) |
| Returns non-null if an ACE_Log_Msg exists for the calling thread. | |
| const ACE_TCHAR * | program_name (void) |
| Returns the current program name used for logging. | |
| void | disable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| void | enable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| ACE_Log_Msg_Backend * | msg_backend (ACE_Log_Msg_Backend *b) |
| ACE_Log_Msg_Backend * | msg_backend (void) |
| void | init_hook (ACE_OS_Log_Msg_Attributes &attributes) |
| 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. | |
Private Member Functions | |
| ACE_Log_Msg & | operator= (const ACE_Log_Msg &) |
| ACE_Log_Msg (const ACE_Log_Msg &) | |
Static Private Member Functions | |
| void | close (void) |
| For cleanup, at program termination. | |
| void | sync_hook (const ACE_TCHAR *prg_name) |
| Decouple the OS layer from the ACE_Log_Msg layer. | |
| 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_ |
| int | restart_ |
| ACE_OSTREAM_TYPE * | ostream_ |
| The ostream where logging messages can be written. | |
| ACE_Log_Msg_Callback * | msg_callback_ |
| The callback object. | |
| int | trace_depth_ |
| Depth of the nesting for printing traces. | |
| int | trace_active_ |
| Are we already within an ACE_Trace constructor call? | |
| int | tracing_enabled_ |
| Are we allowing tracing in this thread? | |
| int | delete_ostream_ |
| Are we deleting this ostream? | |
| ACE_Thread_Descriptor * | thr_desc_ |
| u_long | priority_mask_ |
| int | timestamp_ |
| Always timestamp? | |
| struct { | |
| int is_set_ | |
| const char * file_ | |
| int line_ | |
| int op_status_ | |
| int errnum_ | |
| } | conditional_values_ |
Static Private Attributes | |
| u_long | process_priority_mask_ |
| const ACE_TCHAR * | program_name_ = 0 |
| Records the program name. | |
| const ACE_TCHAR * | local_host_ = 0 |
| Name of the local host (used when printing messages). | |
| pid_t | pid_ = -1 |
| Process id of the current process. | |
| u_long | flags_ = ACE_Log_Msg::STDERR |
| Default is to use stderr. | |
| long | msg_off_ = 0 |
| Offset of msg_[]. | |
| int | instance_count_ = 0 |
| u_long | default_priority_mask_ = 0 |
This class is very flexible since it allows formatted error messages to be printed in a thread-safe manner to various locations, such as stdout, 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 148 of file Log_Msg.h.
|
|
Definition at line 153 of file Log_Msg.h.
00154 {
00155 /// Write messages to stderr.
00156 STDERR = 1,
00157 /// Write messages to the local client logger deamon.
00158 LOGGER = 2,
00159 /// Write messages to the ostream * stored in thread-specific
00160 /// storage.
00161 OSTREAM = 4,
00162 /// Write messages to the callback object.
00163 MSG_CALLBACK = 8,
00164 /// Display messages in a verbose manner.
00165 VERBOSE = 16,
00166 /// Display messages in a less verbose manner (i.e., only print
00167 /// information that can change between calls).
00168 VERBOSE_LITE = 32,
00169 /// Do not print messages at all (just leave in thread-specific
00170 /// storage for later inspection).
00171 SILENT = 64,
00172 /// Write messages to the system's event log.
00173 SYSLOG = 128,
00174 /// Write messages to the user provided backend
00175 CUSTOM = 256
00176 };
|
|
|
Definition at line 407 of file Log_Msg.h.
|
|
|
Initialize logger.
Definition at line 647 of file Log_Msg.cpp. References ACE_GUARD, ACE_MAXLOGMSGLEN, ACE_NEW_NORETURN, ACE_TCHAR, close(), conditional_values_, ACE_OS::getenv(), inherit_hook(), init_hook(), instance_count_, ACE_Base_Thread_Adapter::set_log_msg_hooks(), ACE_OS::strcmp(), sync_hook(), thr_desc_hook(), and timestamp_.
00648 : status_ (0), 00649 errnum_ (0), 00650 linenum_ (0), 00651 msg_ (0), 00652 restart_ (1), // Restart by default... 00653 ostream_ (0), 00654 msg_callback_ (0), 00655 trace_depth_ (0), 00656 trace_active_ (0), 00657 tracing_enabled_ (1), // On by default? 00658 delete_ostream_(0), 00659 thr_desc_ (0), 00660 priority_mask_ (default_priority_mask_), 00661 timestamp_ (0) 00662 { 00663 // ACE_TRACE ("ACE_Log_Msg::ACE_Log_Msg"); 00664 00665 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00666 *ACE_Log_Msg_Manager::get_lock ())); 00667 ++instance_count_; 00668 00669 if (this->instance_count_ == 1) 00670 ACE_Base_Thread_Adapter::set_log_msg_hooks (ACE_Log_Msg::init_hook, 00671 ACE_Log_Msg::inherit_hook, 00672 ACE_Log_Msg::close, 00673 ACE_Log_Msg::sync_hook, 00674 ACE_Log_Msg::thr_desc_hook); 00675 00676 this->conditional_values_.is_set_ = 0; 00677 00678 char *timestamp = ACE_OS::getenv ("ACE_LOG_TIMESTAMP"); 00679 if (timestamp != 0) 00680 { 00681 // If variable is set or is set to date tag so we print date and time. 00682 if (ACE_OS::strcmp (timestamp, "TIME") == 0) 00683 { 00684 this->timestamp_ = 1; 00685 } 00686 else if (ACE_OS::strcmp (timestamp, "DATE") == 0) 00687 { 00688 this->timestamp_ = 2; 00689 } 00690 } 00691 00692 ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]); 00693 } |
|
|
cleanup logger.
Definition at line 695 of file Log_Msg.cpp. References ACE_GUARD, ACE_Log_Msg_Backend::close(), delete_ostream_, ACE_OS::fclose(), ACE_OS::free(), instance_count_, local_host_, msg_, ostream_, and program_name_.
00696 {
00697 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00698
00699 int instance_count;
00700
00701 // Only hold the guard while updating the instance_count_.
00702 // If ACE_Log_Msg_Manager::close () is called, the lock will
00703 // be deleted.
00704 {
00705 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00706 *ACE_Log_Msg_Manager::get_lock ()));
00707 instance_count = --instance_count_;
00708 }
00709 // Release the guard.
00710
00711 #else /* ! ACE_MT_SAFE */
00712 int instance_count = --instance_count_;
00713 #endif /* ! ACE_MT_SAFE */
00714
00715 // If this is the last instance then cleanup. Only the last
00716 // thread to destroy its ACE_Log_Msg instance should execute
00717 // this block.
00718 if (instance_count == 0)
00719 {
00720 // Destroy the message queue instance.
00721 if (ACE_Log_Msg_Manager::log_backend_ != 0)
00722 ACE_Log_Msg_Manager::log_backend_->close ();
00723
00724 // Close down custom backend
00725 if (ACE_Log_Msg_Manager::custom_backend_ != 0)
00726 ACE_Log_Msg_Manager::custom_backend_->close ();
00727
00728 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00729 # if defined (ACE_HAS_TSS_EMULATION)
00730 ACE_Log_Msg_Manager::close ();
00731 # endif /* ACE_HAS_TSS_EMULATION */
00732 # endif /* ACE_MT_SAFE */
00733
00734 if (ACE_Log_Msg::program_name_)
00735 {
00736 ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
00737 ACE_Log_Msg::program_name_ = 0;
00738 }
00739
00740 if (ACE_Log_Msg::local_host_)
00741 {
00742 ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
00743 ACE_Log_Msg::local_host_ = 0;
00744 }
00745 }
00746
00747 //
00748 // do we need to close and clean up?
00749 //
00750 if (this->delete_ostream_ == 1)
00751 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
00752 {
00753 ACE_OS::fclose (this->ostream_);
00754 }
00755 #else
00756 {
00757 delete ostream_;
00758 ostream_ = 0;
00759 }
00760 #endif
00761
00762 delete[] this->msg_;
00763 }
|
|
|
|
|
|
Acquire the internal lock.
Definition at line 590 of file Log_Msg.cpp. References ACE_TRACE, and ACE_Recursive_Thread_Mutex::acquire(). Referenced by ACE_Logging_Strategy::handle_timeout().
00591 {
00592 ACE_TRACE ("ACE_Log_Msg::acquire");
00593 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00594 return ACE_Log_Msg_Manager::get_lock ()->acquire ();
00595 #else /* ! ACE_MT_SAFE */
00596 return 0;
00597 #endif /* ! ACE_MT_SAFE */
00598 }
|
|
|
For cleanup, at program termination.
Definition at line 454 of file Log_Msg.cpp. References ACE_DEBUG, ACE_LIB_TEXT, ACE_Thread::getspecific(), LM_DEBUG, ACE_Thread::setspecific(), ACE_OS::thread_mutex_lock(), and ACE_OS::thread_mutex_unlock(). Referenced by ACE_Log_Msg().
00455 {
00456 // This call needs to go here to avoid memory leaks.
00457 ACE_MT (ACE_Log_Msg_Manager::close ());
00458
00459 // Please note that this will be called by a statement that is
00460 // harded coded into the ACE_Object_Manager's shutdown sequence, in
00461 // its destructor.
00462
00463 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && \
00464 (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00465 defined (ACE_HAS_TSS_EMULATION))
00466
00467 if (key_created_ == 1)
00468 {
00469 ACE_thread_mutex_t *lock =
00470 reinterpret_cast<ACE_thread_mutex_t *> (
00471 ACE_OS_Object_Manager::preallocated_object
00472 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
00473 ACE_OS::thread_mutex_lock (lock);
00474
00475 if (key_created_ == 1)
00476 {
00477 // The same as the ACE_TSS_Cleanup's own key doesn't get
00478 // detached, the log_msg_tss_key_ won't get detached
00479 // until ACE_TSS_Cleanup::free_all_keys_left, so it will
00480 // be in the ACE_TSS_Cleanup::table_. However, there's
00481 // no resource associated with it, so we don't need to
00482 // keyfree it. The dynamic memory associated with it was
00483 // already deleted by ACE_TSS_Cleanup::exit (), so we
00484 // don't want to access it again.
00485 key_created_ = 0;
00486 #ifdef ACE_HAS_BROKEN_THREAD_KEYFREE
00487 // for some systems, e.g. LynxOS, we need to ensure that
00488 // any registered thread destructor action for this thread
00489 // is disabled. Otherwise in the event of a dynamic library
00490 // unload of libACE, by a program not linked with libACE,
00491 // ACE_TSS_cleanup will be invoked after libACE has been unloaded.
00492
00493 ACE_Log_Msg *tss_log_msg = 0;
00494
00495 // Get the tss_log_msg from thread-specific storage.
00496 if ( ACE_Thread::getspecific (*(log_msg_tss_key ()),
00497 ACE_reinterpret_cast (void **, &tss_log_msg)) != -1
00498 && tss_log_msg)
00499 {
00500 // we haven't been cleaned up
00501 ACE_TSS_cleanup(tss_log_msg);
00502
00503 if ( ACE_Thread::setspecific( (*log_msg_tss_key()),
00504 (void *)NULL ) != 0 )
00505 {
00506 ACE_DEBUG ((LM_DEBUG,
00507 ACE_LIB_TEXT ("(%P|%t) ACE_Log_Msg::close failed to ACE_Thread::setspecific to NULL\n")));
00508 }
00509
00510 }
00511 #endif /* ACE_HAS_BROKEN_THREAD_KEYFREE */
00512 }
00513
00514 ACE_OS::thread_mutex_unlock (lock);
00515 }
00516 #endif /* (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) && ACE_MT_SAFE */
00517 }
|
|
|
Disable the bits in the logger's options flags. Definition at line 580 of file Log_Msg.cpp. References ACE_CLR_BITS, ACE_GUARD, ACE_TRACE, and flags_. Referenced by ACE_Logging_Strategy::init().
00581 {
00582 ACE_TRACE ("ACE_Log_Msg::clr_flags");
00583 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00584 *ACE_Log_Msg_Manager::get_lock ()));
00585
00586 ACE_CLR_BITS (ACE_Log_Msg::flags_, flgs);
00587 }
|
|
||||||||||||||||||||
|
These values are only actually set if the requested priority is enabled. Definition at line 2239 of file Log_Msg.cpp. References conditional_values_.
02243 {
02244 this->conditional_values_.is_set_ = 1;
02245 this->conditional_values_.file_ = filename;
02246 this->conditional_values_.line_ = line;
02247 this->conditional_values_.op_status_ = status;
02248 this->conditional_values_.errnum_ = err;
02249 }
|
|
|
Nesting depth decrement.
Definition at line 2353 of file Log_Msg.cpp. References trace_depth_. Referenced by log(), and ACE_Trace::~ACE_Trace().
02354 {
02355 return this->trace_depth_ == 0 ? 0 : --this->trace_depth_;
02356 }
|
|
|
Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances. Definition at line 407 of file Log_Msg.cpp. References ACE_CLR_BITS, default_priority_mask_, instance(), and priority_mask(). Referenced by ACE_Service_Config::fini_svcs(), and ACE_Service_Gestalt::open_i().
00408 {
00409 ACE_CLR_BITS (ACE_Log_Msg::default_priority_mask_, priority);
00410 ACE_Log_Msg *i = ACE_Log_Msg::instance ();
00411 i->priority_mask (i->priority_mask () & ~priority);
00412 }
|
|
|
Dump the state of an object.
Definition at line 2252 of file Log_Msg.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, LM_DEBUG, and ACE_Thread_Descriptor_Base::state().
02253 {
02254 #if defined (ACE_HAS_DUMP)
02255 ACE_TRACE ("ACE_Log_Msg::dump");
02256
02257 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02258 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("status_ = %d\n"), this->status_));
02259 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nerrnum_ = %d\n"), this->errnum_));
02260 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlinenum_ = %d\n"), this->linenum_));
02261 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfile_ = %C\n"), this->file_));
02262 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_ = %s\n"), this->msg_));
02263 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nrestart_ = %d\n"), this->restart_));
02264 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nostream_ = %@\n"), this->ostream_));
02265 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_callback_ = %@\n"),
02266 this->msg_callback_));
02267 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nprogram_name_ = %s\n"),
02268 this->program_name_ ? this->program_name_
02269 : ACE_LIB_TEXT ("<unknown>")));
02270 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlocal_host_ = %s\n"),
02271 this->local_host_ ? this->local_host_
02272 : ACE_LIB_TEXT ("<unknown>")));
02273 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %d\n"), this->getpid ()));
02274 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nflags_ = 0x%x\n"), this->flags_));
02275 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_depth_ = %d\n"),
02276 this->trace_depth_));
02277 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_active_ = %d\n"),
02278 this->trace_active_));
02279 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntracing_enabled_ = %d\n"),
02280 this->tracing_enabled_));
02281 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npriority_mask_ = 0x%x\n"),
02282 this->priority_mask_));
02283 if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0)
02284 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nthr_state_ = %d\n"),
02285 this->thr_desc_->state ()));
02286 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_off_ = %d\n"), this->msg_off_));
02287
02288 // Be sure that there is a message_queue_, with multiple threads.
02289 ACE_MT (ACE_Log_Msg_Manager::init_backend ());
02290
02291 ACE_MT (ACE_Log_Msg_Manager::get_lock ()->dump ());
02292 // Synchronize output operations.
02293
02294 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02295 #endif /* ACE_HAS_DUMP */
02296 }
|
|
|
Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances. Definition at line 396 of file Log_Msg.cpp. References ACE_SET_BITS, default_priority_mask_, instance(), and priority_mask(). Referenced by ACE_Service_Config::fini_svcs(), and ACE_Service_Gestalt::open_i().
00397 {
00398 ACE_SET_BITS (ACE_Log_Msg::default_priority_mask_, priority);
00399 ACE_Log_Msg *i = ACE_Log_Msg::instance ();
00400 i->priority_mask (i->priority_mask () | priority);
00401 }
|
|
|
Get the value of the errnum (by convention this corresponds to errno). Definition at line 2323 of file Log_Msg.cpp. References errnum_. Referenced by set().
02324 {
02325 return this->errnum_;
02326 }
|
|
|
Set the value of the errnum (by convention this corresponds to errno). Definition at line 2329 of file Log_Msg.cpp. References errnum_.
02330 {
02331 this->errnum_ = e;
02332 }
|
|
|
Returns non-null if an ACE_Log_Msg exists for the calling thread.
Definition at line 251 of file Log_Msg.cpp. References ACE_Thread::getspecific(). Referenced by init_hook().
00252 {
00253 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00254 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00255 defined (ACE_HAS_TSS_EMULATION)
00256 ACE_Log_Msg *tss_log_msg = 0;
00257
00258 // Get the tss_log_msg from thread-specific storage.
00259 return key_created_
00260 && ACE_Thread::getspecific (*(log_msg_tss_key ()),
00261 reinterpret_cast<void **> (&tss_log_msg)) != -1
00262 && tss_log_msg;
00263 # else
00264 # error "Platform must support thread-specific storage if threads are used."
00265 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
00266 #else /* ! ACE_MT_SAFE */
00267 return 1;
00268 #endif /* ! ACE_MT_SAFE */
00269 }
|
|
|
Get the file name where an error occurred.
Definition at line 2446 of file Log_Msg.cpp. Referenced by set().
02447 {
02448 return this->file_;
02449 }
|
|
|
Set the file name where an error occurred.
Definition at line 2452 of file Log_Msg.cpp. References ACE_OS::strsncpy().
02453 {
02454 ACE_OS::strsncpy (this->file_, s, sizeof this->file_);
02455 }
|
|
|
Return the bits in the logger's options flags. Definition at line 558 of file Log_Msg.cpp. References ACE_GUARD_RETURN, ACE_TRACE, and flags_. Referenced by ACE_Service_Config::open_i().
00559 {
00560 ACE_TRACE ("ACE_Log_Msg::flags");
00561 u_long result;
00562 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00563 *ACE_Log_Msg_Manager::get_lock (), 0));
00564
00565 result = ACE_Log_Msg::flags_;
00566 return result;
00567 }
|
|
|
Optimize reading of the pid (avoids a system call if the value is cached...). Definition at line 2558 of file Log_Msg.cpp. References ACE_OS::getpid(), and pid_. Referenced by log().
02559 {
02560 if (ACE_Log_Msg::pid_ == -1)
02561 ACE_Log_Msg::pid_ = ACE_OS::getpid ();
02562
02563 return ACE_Log_Msg::pid_;
02564 }
|
|
|
Nesting depth increment.
Definition at line 2347 of file Log_Msg.cpp. References trace_depth_. Referenced by ACE_Trace::ACE_Trace(), and log().
02348 {
02349 return this->trace_depth_++;
02350 }
|
|
||||||||||||
|
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 2610 of file Log_Msg.cpp. References ACE_LOG_MSG, msg_ostream(), ACE_OS_Log_Msg_Attributes::ostream_, priority_mask(), ACE_OS_Log_Msg_Attributes::priority_mask_, restart(), ACE_OS_Log_Msg_Attributes::restart_, start_tracing(), thr_desc(), trace_depth(), ACE_OS_Log_Msg_Attributes::trace_depth_, and ACE_OS_Log_Msg_Attributes::tracing_enabled_. Referenced by ACE_Log_Msg(), and ACE_NT_Service::inherit_log_msg_attributes().
02612 {
02613 #if !defined (ACE_THREADS_DONT_INHERIT_LOG_MSG) && \
02614 !defined (ACE_HAS_MINIMAL_ACE_OS)
02615 // Inherit the logging features if the parent thread has an
02616 // <ACE_Log_Msg>. Note that all of the following operations occur
02617 // within thread-specific storage.
02618 ACE_Log_Msg *new_log = ACE_LOG_MSG;
02619
02620 // Note that we do not inherit the callback because this might have
02621 // been allocated off of the stack of the original thread, in which
02622 // case all hell would break loose...
02623
02624 if (attributes.ostream_)
02625 {
02626 new_log->msg_ostream (attributes.ostream_);
02627 new_log->priority_mask (attributes.priority_mask_);
02628
02629 if (attributes.tracing_enabled_)
02630 new_log->start_tracing ();
02631
02632 new_log->restart (attributes.restart_);
02633 new_log->trace_depth (attributes.trace_depth_);
02634 }
02635
02636 // @@ Now the TSS Log_Msg has been created, cache my thread
02637 // descriptor in.
02638
02639 if (thr_desc != 0)
02640 // This downcast is safe. We do it to avoid having to #include
02641 // ace/Thread_Manager.h.
02642 new_log->thr_desc (static_cast<ACE_Thread_Descriptor *> (thr_desc));
02643 // Block the thread from proceeding until
02644 // thread manager has thread descriptor ready.
02645 #endif /* ! ACE_THREADS_DONT_INHERIT_LOG_MSG && ! ACE_HAS_MINIMAL_ACE_OS */
02646 }
|
|
|
Definition at line 2587 of file Log_Msg.cpp. References ACE_LOG_MSG, exists(), msg_ostream(), priority_mask(), restart(), trace_depth(), and tracing_enabled(). Referenced by ACE_Log_Msg(), and ACE_NT_Service::capture_log_msg_attributes().
02593 {
02594 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
02595 attributes.seh_except_selector_ = selector;
02596 attributes.seh_except_handler_ = handler;
02597 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
02598 if (ACE_Log_Msg::exists ())
02599 {
02600 ACE_Log_Msg *inherit_log = ACE_LOG_MSG;
02601 attributes.ostream_ = inherit_log->msg_ostream ();
02602 attributes.priority_mask_ = inherit_log->priority_mask ();
02603 attributes.tracing_enabled_ = inherit_log->tracing_enabled ();
02604 attributes.restart_ = inherit_log->restart ();
02605 attributes.trace_depth_ = inherit_log->trace_depth ();
02606 }
02607 }
|
|
|
Returns a pointer to the Singleton.
Definition at line 272 of file Log_Msg.cpp. References ACE_NEW_RETURN, ACE_NO_HEAP_CHECK, ACE_Object_Manager::at_exit(), ACE_Thread::getspecific(), ACE_Log_Msg_Manager::init_backend(), ACE_Thread::keycreate(), ACE_Cleanup_Adapter< TYPE >::object(), ACE_Thread::setspecific(), ACE_OS_Object_Manager::starting_up(), ACE_OS::thread_mutex_lock(), and ACE_OS::thread_mutex_unlock(). Referenced by __ace_assert(), disable_debug_messages(), and enable_debug_messages().
00273 {
00274 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00275 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00276 defined (ACE_HAS_TSS_EMULATION)
00277 // TSS Singleton implementation.
00278
00279 if (key_created_ == 0)
00280 {
00281 ACE_thread_mutex_t *lock =
00282 reinterpret_cast<ACE_thread_mutex_t *> (
00283 ACE_OS_Object_Manager::preallocated_object
00284 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
00285
00286 if (1 == ACE_OS_Object_Manager::starting_up())
00287 //This function is called before ACE_OS_Object_Manager is
00288 //initialized. So the lock might not be valid. Assume it's
00289 //single threaded and so don't need the lock.
00290 ;
00291 else
00292 ACE_OS::thread_mutex_lock (lock);
00293
00294 if (key_created_ == 0)
00295 {
00296 // Allocate the Singleton lock.
00297 ACE_Log_Msg_Manager::get_lock ();
00298
00299 {
00300 ACE_NO_HEAP_CHECK;
00301 if (ACE_Thread::keycreate (log_msg_tss_key (),
00302 &ACE_TSS_CLEANUP_NAME) != 0)
00303 {
00304 if (1 == ACE_OS_Object_Manager::starting_up())
00305 //This function is called before ACE_OS_Object_Manager is
00306 //initialized. So the lock might not be valid. Assume it's
00307 //single threaded and so don't need the lock.
00308 ;
00309 else
00310 ACE_OS::thread_mutex_unlock (lock);
00311 return 0; // Major problems, this should *never* happen!
00312 }
00313 }
00314
00315 key_created_ = 1;
00316 }
00317
00318 if (1 == ACE_OS_Object_Manager::starting_up())
00319 //This function is called before ACE_OS_Object_Manager is
00320 //initialized. So the lock might not be valid. Assume it's
00321 //single threaded and so don't need the lock.
00322 ;
00323 else
00324 ACE_OS::thread_mutex_unlock (lock);
00325 }
00326
00327 ACE_Log_Msg *tss_log_msg = 0;
00328
00329 // Get the tss_log_msg from thread-specific storage.
00330 if (ACE_Thread::getspecific (*(log_msg_tss_key ()),
00331 reinterpret_cast<void **> (&tss_log_msg)) == -1)
00332 return 0; // This should not happen!
00333
00334 // Check to see if this is the first time in for this thread.
00335 if (tss_log_msg == 0)
00336 {
00337 // Allocate memory off the heap and store it in a pointer in
00338 // thread-specific storage (on the stack...). Stop heap
00339 // checking, the memory will always be freed by the thread
00340 // rundown because of the TSS callback set up when the key was
00341 // created. This prevents from getting these blocks reported as
00342 // memory leaks.
00343 {
00344 ACE_NO_HEAP_CHECK;
00345
00346 ACE_NEW_RETURN (tss_log_msg,
00347 ACE_Log_Msg,
00348 0);
00349 // Store the dynamically allocated pointer in thread-specific
00350 // storage. It gets deleted via the ACE_TSS_cleanup function
00351 // when the thread terminates.
00352
00353 if (ACE_Thread::setspecific (*(log_msg_tss_key()),
00354 reinterpret_cast<void *> (tss_log_msg))
00355 != 0)
00356 return 0; // Major problems, this should *never* happen!
00357 }
00358 }
00359
00360 return tss_log_msg;
00361 # else
00362 # error "Platform must support thread-specific storage if threads are used."
00363 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
00364 #else /* ! ACE_MT_SAFE */
00365 // We don't have threads, we cannot call
00366 // ACE_Log_Msg_Manager::get_lock () to initialize the logger
00367 // callback, so instead we do it here.
00368 if (ACE_Log_Msg_Manager::init_backend () == -1)
00369 return 0;
00370
00371 // Singleton implementation.
00372 static ACE_Cleanup_Adapter<ACE_Log_Msg> *log_msg = 0;
00373 if (log_msg == 0)
00374 {
00375 ACE_NEW_RETURN (log_msg, ACE_Cleanup_Adapter<ACE_Log_Msg>, 0);
00376 // Register the instance for destruction at program termination.
00377 ACE_Object_Manager::at_exit (log_msg);
00378 }
00379
00380 return &log_msg->object ();
00381 #endif /* ! ACE_MT_SAFE */
00382 }
|
|
|
Returns last error.
Definition at line 387 of file Log_Msg.cpp. References ACE_OS::last_error(). Referenced by __ace_assert().
00388 {
00389 return ACE_OS::last_error ();
00390 }
|
|
|
Get the line number where an error occurred.
Definition at line 2335 of file Log_Msg.cpp. References linenum_. Referenced by set().
02336 {
02337 return this->linenum_;
02338 }
|
|
|
Set the line number where an error occurred.
Definition at line 2341 of file Log_Msg.cpp. References linenum_.
02342 {
02343 this->linenum_ = l;
02344 }
|
|
|
Set the name of the local host.
Definition at line 2538 of file Log_Msg.cpp. References ACE_ALLOCATOR, ACE_NO_HEAP_CHECK, ACE_TCHAR, ACE_OS::free(), and local_host_.
02539 {
02540 if (s)
02541 {
02542 ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
02543 {
02544 ACE_NO_HEAP_CHECK;
02545
02546 ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s));
02547 }
02548 }
02549 }
|
|
|
Get the name of the local host.
Definition at line 2552 of file Log_Msg.cpp. References local_host_.
02553 {
02554 return ACE_Log_Msg::local_host_;
02555 }
|
|
||||||||||||
|
Log a custom built log record to the currently enabled logging sinks. Definition at line 2075 of file Log_Msg.cpp. References ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_GUARD_RETURN, CUSTOM, flags_, local_host_, ACE_Log_Msg_Backend::log(), ACE_Log_Msg_Callback::log(), LOGGER, msg_callback(), MSG_CALLBACK, msg_ostream(), OSTREAM, ACE_Log_Record::print(), SILENT, ssize_t, start_tracing(), STDERR, stop_tracing(), SYSLOG, and tracing_enabled().
02077 {
02078 ssize_t result = 0;
02079
02080 // Format the message and print it to stderr and/or ship it off to
02081 // the log_client daemon, and/or print it to the ostream. Of
02082 // course, only print the message if "SILENT" mode is disabled.
02083 if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_,
02084 ACE_Log_Msg::SILENT))
02085 {
02086 int tracing = this->tracing_enabled ();
02087 this->stop_tracing ();
02088
02089 #if !defined (ACE_WIN32)
02090 // Make this block signal-safe.
02091 ACE_Log_Msg_Sig_Guard sb;
02092 #endif /* !ACE_WIN32 */
02093
02094 // Do the callback, if needed, before acquiring the lock
02095 // to avoid holding the lock during the callback so we don't
02096 // have deadlock if the callback uses the logger.
02097 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
02098 ACE_Log_Msg::MSG_CALLBACK)
02099 && this->msg_callback () != 0)
02100 this->msg_callback ()->log (log_record);
02101
02102 // Make sure that the lock is held during all this.
02103 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
02104 *ACE_Log_Msg_Manager::get_lock (),
02105 -1));
02106
02107 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
02108 ACE_Log_Msg::STDERR)
02109 && !suppress_stderr) // This is taken care of by our caller.
02110 log_record.print (ACE_Log_Msg::local_host_,
02111 ACE_Log_Msg::flags_,
02112 stderr);
02113
02114 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) ||
02115 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG) ||
02116 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER))
02117 {
02118 // Be sure that there is a message_queue_, with multiple threads.
02119 ACE_MT (ACE_Log_Msg_Manager::init_backend ());
02120 }
02121
02122
02123 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER) ||
02124 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SYSLOG))
02125 {
02126 result =
02127 ACE_Log_Msg_Manager::log_backend_->log (log_record);
02128 }
02129
02130 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) &&
02131 ACE_Log_Msg_Manager::custom_backend_ != 0)
02132 {
02133 result =
02134 ACE_Log_Msg_Manager::custom_backend_->log (log_record);
02135 }
02136
02137
02138 // This must come last, after the other two print operations
02139 // (see the <ACE_Log_Record::print> method for details).
02140 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
02141 ACE_Log_Msg::OSTREAM)
02142 && this->msg_ostream () != 0)
02143 log_record.print (ACE_Log_Msg::local_host_,
02144 ACE_Log_Msg::flags_,
02145 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
02146 static_cast<FILE *> (this->msg_ostream ())
02147 #else /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02148 *this->msg_ostream ()
02149 #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02150 );
02151
02152 if (tracing)
02153 this->start_tracing ();
02154 }
02155
02156 return result;
02157 }
|
|
||||||||||||||||
|
An alternative logging mechanism that makes it possible to integrate variable argument lists from other logging mechanisms into the ACE mechanism. Definition at line 974 of file Log_Msg.cpp. References ACE_OS::abort(), ACE_BIT_ENABLED, ACE_hthread_t, ACE_INT64, ACE_INT64_FORMAT_SPECIFIER, ACE_LIB_TEXT, ACE_MAXLOGMSGLEN, ACE_NEW_NORETURN, ACE_NSIG, ACE_TCHAR, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRACE, ACE_UINT64, ACE_UINT64_FORMAT_SPECIFIER, ACE_UPDATE_COUNT, conditional_values_, dec(), flags_, ACE_OS::fprintf(), ACE_Trace::get_nesting_indent(), getpid(), inc(), local_host_, log(), log_priority_enabled(), ACE::map_errno(), msg(), msg_, msg_callback(), ACE_Log_Record::msg_data(), msg_off_, msg_ostream(), op_status(), ACE_Log_Record::print(), ACE_Log_Record::priority_name(), program_name_, ACE_Thread::self(), set(), SILENT, ACE_OS::snprintf(), ACE::sock_error(), ACE_OS::sprintf(), ssize_t, ACE_OS::strcpy(), ACE_OS::strerror(), ACE_OS::strlen(), ACE_OS::strsncpy(), ACE::timestamp(), timestamp_, trace_depth_, VERBOSE, and ACE_OS::wslen().
00977 {
00978 ACE_TRACE ("ACE_Log_Msg::log");
00979 // External decls.
00980
00981 typedef void (*PTF)(...);
00982
00983 // Check if there were any conditional values set.
00984 int conditional_values = this->conditional_values_.is_set_;
00985
00986 // Reset conditional values.
00987 this->conditional_values_.is_set_ = 0;
00988
00989 // Only print the message if <priority_mask_> hasn't been reset to
00990 // exclude this logging priority.
00991 if (this->log_priority_enabled (log_priority) == 0)
00992 return 0;
00993
00994 // If conditional values were set and the log priority is correct,
00995 // then the values are actually set.
00996 if (conditional_values)
00997 this->set (this->conditional_values_.file_,
00998 this->conditional_values_.line_,
00999 this->conditional_values_.op_status_,
01000 this->conditional_values_.errnum_,
01001 this->restart (),
01002 this->msg_ostream (),
01003 this->msg_callback ());
01004
01005 // Logging is supposed to be a benign activity (i.e., not interfer
01006 // with normal application operations), so don't inadvertently smash
01007 // errno!
01008 ACE_Errno_Guard guard (errno);
01009
01010 ACE_Log_Record log_record (log_priority,
01011 ACE_OS::gettimeofday (),
01012 this->getpid ());
01013 // bp is pointer to where to put next part of logged message.
01014 // bspace is the number of characters remaining in msg_.
01015 ACE_TCHAR *bp = const_cast<ACE_TCHAR *> (this->msg ());
01016 size_t bspace = ACE_Log_Record::MAXLOGMSGLEN; // Leave room for Nul term.
01017 if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN)
01018 bspace -= static_cast<size_t> (this->msg_off_);
01019
01020 // If this platform has snprintf() capability to prevent overrunning the
01021 // output buffer, use it. To avoid adding a maintenance-hassle compile-
01022 // time couple between here and OS.cpp, don't try to figure this out at
01023 // compile time. Instead, do a quick check now; if we get a -1 return,
01024 // the platform doesn't support the length-limiting capability.
01025 ACE_TCHAR test[2];
01026 int can_check = ACE_OS::snprintf (test, 1, ACE_LIB_TEXT ("x")) != -1;
01027
01028 int abort_prog = 0;
01029 int exit_value = 0;
01030
01031 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE))
01032 {
01033 // Prepend the program name onto this message
01034
01035 if (ACE_Log_Msg::program_name_ != 0)
01036 {
01037 for (const ACE_TCHAR *s = ACE_Log_Msg::program_name_;
01038 bspace > 1 && (*bp = *s) != '\0';
01039 ++s, --bspace)
01040 bp++;
01041
01042 *bp++ = '|';
01043 --bspace;
01044 }
01045 }
01046
01047 if (timestamp_ > 0)
01048 {
01049 ACE_TCHAR day_and_time[35];
01050 const ACE_TCHAR *s;
01051 if (timestamp_ == 1)
01052 {
01053 // Print just the time
01054 s = ACE::timestamp (day_and_time, sizeof day_and_time, 1);
01055 }
01056 else
01057 {
01058 // Print time and date
01059 ACE::timestamp (day_and_time, sizeof day_and_time);
01060 s = day_and_time;
01061 }
01062
01063 for (; bspace > 1 && (*bp = *s) != '\0'; ++s, --bspace)
01064 ++bp;
01065
01066 *bp++ = '|';
01067 --bspace;
01068 }
01069
01070 while (*format_str != '\0' && bspace > 0)
01071 {
01072 // Copy input to output until we encounter a %, however a
01073 // % followed by another % is not a format specification.
01074
01075 if (*format_str != '%')
01076 {
01077 *bp++ = *format_str++;
01078 --bspace;
01079 }
01080 else if (format_str[1] == '%') // An "escaped" '%' (just print one '%').
01081 {
01082 *bp++ = *format_str++; // Store first %
01083 ++format_str; // but skip second %
01084 --bspace;
01085 }
01086 else
01087 {
01088 // This is most likely a format specification that ends with
01089 // one of the valid options described previously. To enable full
01090 // use of all sprintf capabilities, save the format specifier
01091 // from the '%' up to the format letter in a new char array.
01092 // This allows the full sprintf capability for padding, field
01093 // widths, alignment, etc. Any width/precision requiring a
01094 // caller-supplied argument is extracted and placed as text
01095 // into the format array. Lastly, we convert the caller-supplied
01096 // format specifier from the ACE_Log_Msg-supported list to the
01097 // equivalent sprintf specifier, and run the new format spec
01098 // through sprintf, adding it to the bp string.
01099
01100 const ACE_TCHAR *abort_str = ACE_LIB_TEXT ("Aborting...");
01101 const ACE_TCHAR *start_format = format_str;
01102 ACE_TCHAR format[128]; // Converted format string
01103 ACE_TCHAR *fp; // Current format pointer
01104 int wp = 0; // Width/precision extracted from args
01105 int done = 0;
01106 int skip_nul_locate = 0;
01107 int this_len = 0; // How many chars s[n]printf wrote
01108
01109 fp = format;
01110 *fp++ = *format_str++; // Copy in the %
01111
01112 // Initialization to satisfy VC6
01113 int tmp_indent = 0;
01114 // Work through the format string to copy in the format
01115 // from the caller. While it's going across, extract ints
01116 // for '*' width/precision values from the argument list.
01117 // When the real format specifier is located, change it to
01118 // one recognized by sprintf, if needed, and do the sprintf
01119 // call.
01120
01121 while (!done)
01122 {
01123 done = 1; // Unless a conversion spec changes it
01124
01125 switch (*format_str)
01126 {
01127 // The initial set of cases are the conversion
01128 // specifiers. Copy them in to the format array.
01129 // Note we don't use 'l', a normal conversion spec,
01130 // as a conversion because it is a ACE_Log_Msg format
01131 // specifier.
01132 case '-':
01133 case '+':
01134 case '0':
01135 case ' ':
01136 case '#':
01137 case '1':
01138 case '2':
01139 case '3':
01140 case '4':
01141 case '5':
01142 case '6':
01143 case '7':
01144 case '8':
01145 case '9':
01146 case '.':
01147 case 'L':
01148 case 'h':
01149 *fp++ = *format_str;
01150 done = 0;
01151 break;
01152
01153 case '*':
01154 wp = va_arg (argp, int);
01155 ACE_OS::sprintf (fp, ACE_LIB_TEXT ("%d"), wp);
01156 fp += ACE_OS::strlen (fp);
01157 done = 0;
01158 break;
01159
01160 case 'A': // ACE_timer_t
01161 {
01162 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("f"));
01163 double value = va_arg (argp, double);
01164 if (can_check)
01165 this_len = ACE_OS::snprintf (bp, bspace, format, value);
01166 else
01167 this_len = ACE_OS::sprintf (bp, format, value);
01168 ACE_UPDATE_COUNT (bspace, this_len);
01169 }
01170 break;
01171
01172 case 'a': // Abort program after handling all of format string.
01173 abort_prog = 1;
01174 exit_value = va_arg (argp, int);
01175 ACE_OS::strsncpy (bp, abort_str, bspace);
01176 if (bspace > ACE_OS::strlen (abort_str))
01177 bspace -= ACE_OS::strlen (abort_str);
01178 else
01179 bspace = 0;
01180 break;
01181
01182 case 'l': // Source file line number
01183 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01184 if (can_check)
01185 this_len = ACE_OS::snprintf (bp,
01186 bspace,
01187 format,
01188 this->linenum ());
01189 else
01190 this_len = ACE_OS::sprintf (bp, format, this->linenum ());
01191 ACE_UPDATE_COUNT (bspace, this_len);
01192 break;
01193
01194 case 'N': // Source file name
01195 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01196 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01197 #else
01198 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01199 #endif
01200 if (can_check)
01201 this_len = ACE_OS::snprintf (bp, bspace, format,
01202 this->file () ?
01203 ACE_TEXT_CHAR_TO_TCHAR (this->file ())
01204 : ACE_LIB_TEXT ("<unknown file>"));
01205 else
01206 this_len = ACE_OS::sprintf (bp, format,
01207 this->file () ?
01208 ACE_TEXT_CHAR_TO_TCHAR (this->file ())
01209 : ACE_LIB_TEXT ("<unknown file>"));
01210 ACE_UPDATE_COUNT (bspace, this_len);
01211 break;
01212
01213 case 'n': // Program name
01214 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01215 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01216 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01217 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01218 #endif
01219 if (can_check)
01220 this_len = ACE_OS::snprintf (bp, bspace, format,
01221 ACE_Log_Msg::program_name_ ?
01222 ACE_Log_Msg::program_name_ :
01223 ACE_LIB_TEXT ("<unknown>"));
01224 else
01225 this_len = ACE_OS::sprintf (bp, format,
01226 ACE_Log_Msg::program_name_ ?
01227 ACE_Log_Msg::program_name_ :
01228 ACE_LIB_TEXT ("<unknown>"));
01229 ACE_UPDATE_COUNT (bspace, this_len);
01230 break;
01231
01232 case 'P': // Process ID
01233 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01234 if (can_check)
01235 this_len = ACE_OS::snprintf
01236 (bp, bspace, format,
01237 static_cast<int> (this->getpid ()));
01238 else
01239 this_len = ACE_OS::sprintf
01240 (bp, format, static_cast<int> (this->getpid ()));
01241 ACE_UPDATE_COUNT (bspace, this_len);
01242 break;
01243
01244 case 'p': // <errno> string, ala perror()
01245 {
01246 errno = 0;
01247 char *msg;
01248 msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
01249 // Windows can try to translate the errnum using
01250 // system calls if strerror() doesn't get anything useful.
01251 #if defined (ACE_WIN32)
01252 if (errno == 0)
01253 {
01254 #endif
01255
01256 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01257 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls: %ls"));
01258 #else
01259 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01260 #endif
01261 if (can_check)
01262 this_len = ACE_OS::snprintf
01263 (bp, bspace, format, va_arg (argp, ACE_TCHAR *),
01264 ACE_TEXT_CHAR_TO_TCHAR (msg));
01265 else
01266 this_len = ACE_OS::sprintf
01267 (bp, format, va_arg (argp, ACE_TCHAR *),
01268 ACE_TEXT_CHAR_TO_TCHAR (msg));
01269 #if defined (ACE_WIN32)
01270 }
01271 else
01272 {
01273 errno = ACE::map_errno (this->errnum ());
01274 ACE_TCHAR *lpMsgBuf = 0;
01275
01276 // PharLap can't do FormatMessage, so try for socket
01277 // error.
01278 # if !defined (ACE_HAS_PHARLAP)
01279 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
01280 | FORMAT_MESSAGE_MAX_WIDTH_MASK
01281 | FORMAT_MESSAGE_FROM_SYSTEM,
01282 0,
01283 errno,
01284 MAKELANGID (LANG_NEUTRAL,
01285 SUBLANG_DEFAULT),
01286 // Default language
01287 (ACE_TCHAR *) &lpMsgBuf,
01288 0,
01289 0);
01290 # endif /* ACE_HAS_PHARLAP */
01291
01292 // If we don't get a valid response from
01293 // <FormatMessage>, we'll assume this is a
01294 // WinSock error and so we'll try to convert
01295 // it into a string. If this doesn't work it
01296 // returns "unknown error" which is fine for
01297 // our purposes.
01298 if (lpMsgBuf == 0)
01299 {
01300 const ACE_TCHAR *message =
01301 ACE::sock_error (errno);
01302 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01303 if (can_check)
01304 this_len = ACE_OS::snprintf
01305 (bp, bspace, format,
01306 va_arg (argp, const ACE_TCHAR *),
01307 message);
01308 else
01309 this_len = ACE_OS::sprintf
01310 (bp, format,
01311 va_arg (argp, const ACE_TCHAR *),
01312 message);
01313 }
01314 else
01315 {
01316 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01317 if (can_check)
01318 this_len = ACE_OS::snprintf
01319 (bp, bspace, format,
01320 va_arg (argp, ACE_TCHAR *),
01321 lpMsgBuf);
01322 else
01323 this_len = ACE_OS::sprintf
01324 (bp, format,
01325 va_arg (argp, ACE_TCHAR *),
01326 lpMsgBuf);
01327 // Free the buffer.
01328 ::LocalFree (lpMsgBuf);
01329 }
01330 }
01331 #endif /* ACE_WIN32 */
01332 ACE_UPDATE_COUNT (bspace, this_len);
01333 break;
01334 }
01335
01336 case 'M': // Print the name of the priority of the message.
01337 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01338 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01339 #else
01340 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01341 #endif
01342 if (can_check)
01343 this_len = ACE_OS::snprintf
01344 (bp, bspace, format,
01345 ACE_Log_Record::priority_name (log_priority));
01346 else
01347 this_len = ACE_OS::sprintf
01348 (bp, format,
01349 ACE_Log_Record::priority_name (log_priority));
01350 ACE_UPDATE_COUNT (bspace, this_len);
01351 break;
01352
01353 case 'm': // Format the string assocated with the errno value.
01354 {
01355 errno = 0;
01356 char *msg;
01357 msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
01358 // Windows can try to translate the errnum using
01359 // system calls if strerror() doesn't get anything useful.
01360 #if defined (ACE_WIN32)
01361 if (errno == 0)
01362 {
01363 #endif
01364
01365 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01366 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01367 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01368 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01369 #endif
01370 if (can_check)
01371 this_len = ACE_OS::snprintf
01372 (bp, bspace, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
01373 else
01374 this_len = ACE_OS::sprintf
01375 (bp, format, ACE_TEXT_CHAR_TO_TCHAR (msg));
01376 #if defined (ACE_WIN32)
01377 }
01378 else
01379 {
01380 errno = ACE::map_errno (this->errnum ());
01381 ACE_TCHAR *lpMsgBuf = 0;
01382
01383 // PharLap can't do FormatMessage, so try for socket
01384 // error.
01385 # if !defined (ACE_HAS_PHARLAP)
01386 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
01387 | FORMAT_MESSAGE_MAX_WIDTH_MASK
01388 | FORMAT_MESSAGE_FROM_SYSTEM,
01389 0,
01390 errno,
01391 MAKELANGID (LANG_NEUTRAL,
01392 SUBLANG_DEFAULT),
01393 // Default language
01394 (ACE_TCHAR *) &lpMsgBuf,
01395 0,
01396 0);
01397 # endif /* ACE_HAS_PHARLAP */
01398
01399 // If we don't get a valid response from
01400 // <FormatMessage>, we'll assume this is a
01401 // WinSock error and so we'll try to convert
01402 // it into a string. If this doesn't work it
01403 // returns "unknown error" which is fine for
01404 // our purposes.
01405 if (lpMsgBuf == 0)
01406 {
01407 const ACE_TCHAR *message =
01408 ACE::sock_error (errno);
01409 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01410 if (can_check)
01411 this_len = ACE_OS::snprintf
01412 (bp, bspace, format, message);
01413 else
01414 this_len = ACE_OS::sprintf (bp, format, message);
01415 }
01416 else
01417 {
01418 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01419 if (can_check)
01420 this_len = ACE_OS::snprintf
01421 (bp, bspace, format, lpMsgBuf);
01422 else
01423 this_len = ACE_OS::sprintf
01424 (bp, format, lpMsgBuf);
01425 // Free the buffer.
01426 ::LocalFree (lpMsgBuf);
01427 }
01428 }
01429 #endif /* ACE_WIN32 */
01430 ACE_UPDATE_COUNT (bspace, this_len);
01431 break;
01432 }
01433
01434 case 'R': // Format the return status of the operation.
01435 this->op_status (va_arg (argp, int));
01436 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01437 if (can_check)
01438 this_len = ACE_OS::snprintf
01439 (bp, bspace, format, this->op_status ());
01440 else
01441 this_len = ACE_OS::sprintf
01442 (bp, format, this->op_status ());
01443 ACE_UPDATE_COUNT (bspace, this_len);
01444 break;
01445
01446 case '{': // Increment the trace_depth, then indent
01447 skip_nul_locate = 1;
01448 (void) this->inc ();
01449 break;
01450
01451 case '}': // indent, then decrement trace_depth
01452 skip_nul_locate = 1;
01453 (void) this->dec ();
01454 break;
01455
01456 case '$': // insert a newline, then indent the next line
01457 // according to %I
01458 *bp++ = '\n';
01459 --bspace;
01460 /* fallthrough */
01461
01462 case 'I': // Indent with nesting_depth*width spaces
01463 // Caller can do %*I to override nesting indent, and
01464 // if %*I was done, wp has the extracted width.
01465 #if defined (ACE_HAS_TRACE)
01466 if (0 == wp)
01467 wp = ACE_Trace::get_nesting_indent ();
01468 #else
01469 if (0 == wp)
01470 wp = 4;
01471 #endif /* ACE_HAS_TRACE */
01472 wp *= this->trace_depth_;
01473 if (static_cast<size_t> (wp) > bspace)
01474 wp = static_cast<int> (bspace);
01475 for (tmp_indent = wp;
01476 tmp_indent;
01477 --tmp_indent)
01478 *bp++ = ' ';
01479
01480 *bp = '\0';
01481 bspace -= static_cast<size_t> (wp);
01482 skip_nul_locate = 1;
01483 break;
01484
01485 case 'r': // Run (invoke) this subroutine.
01486 {
01487 long osave = ACE_Log_Msg::msg_off_;
01488
01489 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01490 ACE_Log_Msg::SILENT) &&
01491 bspace > 1)
01492 {
01493 *bp++ = '{';
01494 --bspace;
01495 }
01496 ACE_Log_Msg::msg_off_ = bp - this->msg_;
01497
01498 (*va_arg (argp, PTF))();
01499
01500 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01501 ACE_Log_Msg::SILENT) &&
01502 bspace > (1 + ACE_OS::strlen (bp)))
01503 {
01504 bspace -= (ACE_OS::strlen (bp) + 1);
01505 bp += ACE_OS::strlen (bp);
01506 *bp++ = '}';
01507 }
01508 *bp = '\0';
01509 skip_nul_locate = 1;
01510 ACE_Log_Msg::msg_off_ = osave;
01511 break;
01512 }
01513
01514 case 'S': // format the string for with this signal number.
01515 {
01516 int sig = va_arg (argp, int);
01517 #if defined (ACE_HAS_SYS_SIGLIST)
01518 if (sig >= 0 && sig < ACE_NSIG)
01519 {
01520 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01521 if (can_check)
01522 this_len = ACE_OS::snprintf
01523 (bp, bspace, format, _sys_siglist[sig]);
01524 else
01525 this_len = ACE_OS::sprintf
01526 (bp, format, _sys_siglist[sig]);
01527 }
01528 else
01529 {
01530 if (can_check)
01531 this_len = ACE_OS::snprintf
01532 (bp, bspace,
01533 ACE_LIB_TEXT("<unknown signal> %d"), sig);
01534 else
01535 this_len = ACE_OS::sprintf
01536 (bp, ACE_LIB_TEXT ("<unknown signal> %d"), sig);
01537 }
01538 #else
01539 if (can_check)
01540 this_len = ACE_OS::snprintf
01541 (bp, bspace, ACE_LIB_TEXT ("signal %d"), sig);
01542 else
01543 this_len = ACE_OS::sprintf
01544 (bp, ACE_LIB_TEXT ("signal %d"), sig);
01545 #endif /* ACE_HAS_SYS_SIGLIST */
01546 ACE_UPDATE_COUNT (bspace, this_len);
01547 break;
01548 }
01549
01550 case 'D': // Format the timestamp in month/day/year
01551 // hour:minute:sec:usec format.
01552 {
01553 ACE_TCHAR day_and_time[35];
01554 ACE::timestamp (day_and_time,
01555 sizeof day_and_time);
01556 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01557 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01558 #else
01559 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01560 #endif
01561 if (can_check)
01562 this_len = ACE_OS::snprintf
01563 (bp, bspace, format, day_and_time);
01564 else
01565 this_len = ACE_OS::sprintf (bp, format, day_and_time);
01566 ACE_UPDATE_COUNT (bspace, this_len);
01567 break;
01568 }
01569
01570 case 'T': // Format the timestamp in
01571 // hour:minute:sec:usec format.
01572 {
01573 ACE_TCHAR day_and_time[35];
01574 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01575 if (can_check)
01576 this_len = ACE_OS::snprintf
01577 (bp, bspace, format,
01578 ACE::timestamp (day_and_time, sizeof day_and_time));
01579 else
01580 this_len = ACE_OS::sprintf
01581 (bp, format, ACE::timestamp (day_and_time,
01582 sizeof day_and_time));
01583 ACE_UPDATE_COUNT (bspace, this_len);
01584 break;
01585 }
01586
01587 case 't': // Format thread id.
01588 #if defined (ACE_WIN32)
01589 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01590 if (can_check)
01591 this_len = ACE_OS::snprintf
01592 (bp, bspace, format,
01593 static_cast<unsigned> (ACE_Thread::self ()));
01594 else
01595 this_len =
01596 ACE_OS::sprintf (bp,
01597 format,
01598 static_cast <unsigned> (ACE_Thread::self ()));
01599 #elif defined (ACE_AIX_VERS) && (ACE_AIX_VERS <= 402)
01600 // AIX's pthread_t (ACE_hthread_t) is a pointer, and it's
01601 // a little ugly to send that through a %u format. So,
01602 // get the kernel thread ID (tid_t) via thread_self() and
01603 // display that instead.
01604 // This isn't conditionalized on ACE_HAS_THREAD_SELF because
01605 // 1. AIX 4.2 doesn't have that def anymore (it messes up
01606 // other things)
01607 // 2. OSF/1 V3.2 has that def, and I'm not sure what affect
01608 // this would have on that.
01609 // -Steve Huston, 19-Aug-97
01610 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01611 if (can_check)
01612 this_len = ACE_OS::snprintf
01613 (bp, bspace, format, thread_self());
01614 else
01615 this_len = ACE_OS::sprintf (bp, format, thread_self());
01616 #elif defined (DIGITAL_UNIX)
01617 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01618 {
01619 int id =
01620 # if defined (ACE_HAS_THREADS)
01621 pthread_getselfseq_np ();
01622 # else
01623 ACE_Thread::self ();
01624 # endif /* ACE_HAS_THREADS */
01625
01626 if (can_check)
01627 this_len = ACE_OS::snprintf (bp, bspace, format, id);
01628 else
01629 this_len = ACE_OS::sprintf (bp, format, id);
01630 }
01631 #else
01632 ACE_hthread_t t_id;
01633 ACE_Thread::self (t_id);
01634
01635 # if defined (ACE_MVS) || defined (ACE_TANDEM_T1248_PTHREADS)
01636 // MVS's pthread_t is a struct... yuck. So use the ACE 5.0
01637 // code for it.
01638 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01639 if (can_check)
01640 this_len = ACE_OS::snprintf (bp, bspace, format, t_id);
01641 else
01642 this_len = ACE_OS::sprintf (bp, format, t_id);
01643 # else
01644 // Yes, this is an ugly C-style cast, but the correct
01645 // C++ cast is different depending on whether the t_id
01646 // is an integral type or a pointer type. FreeBSD uses
01647 // a pointer type, but doesn't have a _np function to
01648 // get an integral type, like the OSes above.
01649 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lu"));
01650 if (can_check)
01651 this_len = ACE_OS::snprintf
01652 (bp, bspace, format, (unsigned long)t_id);
01653 else
01654 this_len = ACE_OS::sprintf
01655 (bp, format, (unsigned long)t_id);
01656 # endif /* ACE_MWS || ACE_TANDEM_T1248_PTHREADS */
01657
01658 #endif /* ACE_WIN32 */
01659 ACE_UPDATE_COUNT (bspace, this_len);
01660 break;
01661
01662 case 's': // String
01663 {
01664 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01665 wchar_t *str = va_arg (argp, wchar_t *);
01666 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01667 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01668 ACE_TCHAR *str = va_arg (argp, ACE_TCHAR *);
01669 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01670 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01671 if (can_check)
01672 this_len = ACE_OS::snprintf
01673 (bp, bspace, format, str ? str : ACE_LIB_TEXT ("(null)"));
01674 else
01675 this_len = ACE_OS::sprintf
01676 (bp, format, str ? str : ACE_LIB_TEXT ("(null)"));
01677 ACE_UPDATE_COUNT (bspace, this_len);
01678 }
01679 break;
01680
01681 case 'C': // Char string, Unicode for Win32/WCHAR
01682 {
01683 ACE_TCHAR *cstr = va_arg (argp, ACE_TCHAR *);
01684 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01685 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01686 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01687 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01688 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01689 if (can_check)
01690 this_len = ACE_OS::snprintf
01691 (bp, bspace, format, cstr ? cstr : ACE_LIB_TEXT ("(null)"));
01692 else
01693 this_len = ACE_OS::sprintf
01694 (bp, format, cstr ? cstr : ACE_LIB_TEXT ("(null)"));
01695 ACE_UPDATE_COUNT (bspace, this_len);
01696 }
01697 break;
01698
01699 case 'W':
01700 {
01701 #if defined (ACE_WIN32)
01702 ACE_TCHAR *wstr = va_arg (argp, ACE_TCHAR *);
01703 # if defined (ACE_USES_WCHAR)
01704 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01705 # else /* ACE_USES_WCHAR */
01706 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01707 # endif /* ACE_USES_WCHAR */
01708 if (can_check)
01709 this_len = ACE_OS::snprintf
01710 (bp, bspace, format, wstr ? wstr : ACE_LIB_TEXT ("(null)"));
01711 else
01712 this_len = ACE_OS::sprintf
01713 (bp, format, wstr ? wstr : ACE_LIB_TEXT ("(null)"));
01714 #elif defined (ACE_HAS_WCHAR)
01715 wchar_t *wchar_str = va_arg (argp, wchar_t *);
01716 # if defined (HPUX)
01717 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01718 # else
01719 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01720 # endif /* HPUX */
01721 if (can_check)
01722 this_len = ACE_OS::snprintf
01723 (bp, bspace, format, wchar_str);
01724 else
01725 this_len = ACE_OS::sprintf
01726 (bp, format, wchar_str);
01727 #endif /* ACE_WIN32 / ACE_HAS_WCHAR */
01728 ACE_UPDATE_COUNT (bspace, this_len);
01729 }
01730 break;
01731
01732 case 'w': // Wide character
01733 #if defined (ACE_WIN32)
01734 # if defined (ACE_USES_WCHAR)
01735 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01736 # else /* ACE_USES_WCHAR */
01737 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01738 # endif /* ACE_USES_WCHAR */
01739 if (can_check)
01740 this_len = ACE_OS::snprintf
01741 (bp, bspace, format, va_arg (argp, int));
01742 else
01743 this_len = ACE_OS::sprintf
01744 (bp, format, va_arg (argp, int));
01745 #elif defined (ACE_USES_WCHAR)
01746 # if defined (HPUX)
01747 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01748 # else
01749 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lc"));
01750 # endif /* HPUX */
01751 if (can_check)
01752 this_len = ACE_OS::snprintf
01753 (bp, bspace, format, va_arg (argp, wint_t));
01754 else
01755 this_len = ACE_OS::sprintf
01756 (bp, format, va_arg (argp, wint_t));
01757 #else /* ACE_WIN32 */
01758 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01759 if (can_check)
01760 this_len = ACE_OS::snprintf
01761 (bp, bspace, format, va_arg (argp, int));
01762 else
01763 this_len = ACE_OS::sprintf
01764 (bp, format, va_arg (argp, int));
01765 #endif /* ACE_WIN32 */
01766 ACE_UPDATE_COUNT (bspace, this_len);
01767 break;
01768
01769 case 'z': // ACE_OS::WChar character
01770 {
01771 // On some platforms sizeof (wchar_t) can be 2
01772 // on the others 4 ...
01773 wchar_t wtchar =
01774 static_cast<wchar_t> (va_arg (argp, int));
01775 #if defined (ACE_WIN32)
01776 # if defined (ACE_USES_WCHAR)
01777 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01778 # else /* ACE_USES_WCHAR */
01779 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01780 # endif /* ACE_USES_WCHAR */
01781 #elif defined (ACE_USES_WCHAR)
01782 # if defined (HPUX)
01783 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01784 # else
01785 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lc"));
01786 # endif /* HPUX */
01787 #else /* ACE_WIN32 */
01788 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01789 #endif /* ACE_WIN32 */
01790 if (can_check)
01791 this_len = ACE_OS::snprintf (bp, bspace, format, wtchar);
01792 else
01793 this_len = ACE_OS::sprintf (bp, format, wtchar);
01794 ACE_UPDATE_COUNT (bspace, this_len);
01795 break;
01796 }
01797
01798 case 'Z': // ACE_OS::WChar character string
01799 {
01800 ACE_OS::WChar *wchar_str = va_arg (argp, ACE_OS::WChar*);
01801 if (wchar_str == 0)
01802 break;
01803
01804 wchar_t *wchar_t_str = 0;
01805 if (sizeof (ACE_OS::WChar) != sizeof (wchar_t))
01806 {
01807 size_t len = ACE_OS::wslen (wchar_str) + 1;
01808 ACE_NEW_NORETURN(wchar_t_str, wchar_t[len]);
01809 if (wchar_t_str == 0)
01810 break;
01811
01812 for (size_t i = 0; i < len; ++i)
01813 {
01814 wchar_t_str[i] = wchar_str[i];
01815 }
01816 }
01817
01818 if (wchar_t_str == 0)
01819 {
01820 wchar_t_str = reinterpret_cast<wchar_t*> (wchar_str);
01821 }
01822 #if defined (ACE_WIN32)
01823 # if defined (ACE_USES_WCHAR)
01824 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01825 # else /* ACE_USES_WCHAR */
01826 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01827 # endif /* ACE_USES_WCHAR */
01828 #elif defined (ACE_HAS_WCHAR)
01829 # if defined (HPUX)
01830 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01831 # else
01832 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01833 # endif /* HPUX */
01834 #endif /* ACE_WIN32 / ACE_HAS_WCHAR */
01835 if (can_check)
01836 this_len = ACE_OS::snprintf
01837 (bp, bspace, format, wchar_t_str);
01838 else
01839 this_len = ACE_OS::sprintf (bp, format, wchar_t_str);
01840 if(sizeof(ACE_OS::WChar) != sizeof(wchar_t))
01841 {
01842 delete wchar_t_str;
01843 }
01844 ACE_UPDATE_COUNT (bspace, this_len);
01845 break;
01846 }
01847
01848 case 'c':
01849 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01850 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01851 #else
01852 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01853 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01854 if (can_check)
01855 this_len = ACE_OS::snprintf
01856 (bp, bspace, format, va_arg (argp, int));
01857 else
01858 this_len = ACE_OS::sprintf
01859 (bp, format, va_arg (argp, int));
01860 ACE_UPDATE_COUNT (bspace, this_len);
01861 break;
01862
01863 case 'd': case 'i': case 'o':
01864 case 'u': case 'x': case 'X':
01865 fp[0] = *format_str;
01866 fp[1] = '\0';
01867 if (can_check)
01868 this_len = ACE_OS::snprintf
01869 (bp, bspace, format, va_arg (argp, int));
01870 else
01871 this_len = ACE_OS::sprintf
01872 (bp, format, va_arg (argp, int));
01873 ACE_UPDATE_COUNT (bspace, this_len);
01874 break;
01875
01876 case 'F': case 'f': case 'e': case 'E':
01877 case 'g': case 'G':
01878 fp[0] = *format_str;
01879 fp[1] = '\0';
01880 if (can_check)
01881 this_len = ACE_OS::snprintf
01882 (bp, bspace, format, va_arg (argp, double));
01883 else
01884 this_len = ACE_OS::sprintf
01885 (bp, format, va_arg (argp, double));
01886 ACE_UPDATE_COUNT (bspace, this_len);
01887 break;
01888
01889 case 'Q':
01890 #if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
01891 {
01892 // This relies on the ACE_U_LongLong storage layout.
01893 ACE_UINT32 hi = va_arg (argp, ACE_UINT32);
01894 ACE_UINT32 lo = va_arg (argp, ACE_UINT32);
01895 if (hi > 0)
01896 this_len = ACE_OS::sprintf (bp,
01897 "0x%lx%0*lx",
01898 hi,
01899 2 * sizeof lo,
01900 lo);
01901 else
01902 this_len = ACE_OS::sprintf (bp, "0x%lx", lo);
01903 }
01904 #else /* ! ACE_LACKS_LONGLONG_T */
01905 {
01906 const ACE_TCHAR *fmt = ACE_UINT64_FORMAT_SPECIFIER;
01907 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
01908 if (can_check)
01909 this_len = ACE_OS::snprintf (bp, bspace,
01910 format,
01911 va_arg (argp, ACE_UINT64));
01912 else
01913 this_len = ACE_OS::sprintf (bp,
01914 format,
01915 va_arg (argp, ACE_UINT64));
01916 }
01917 #endif /* ! ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */
01918 ACE_UPDATE_COUNT (bspace, this_len);
01919 break;
01920
01921 case 'q':
01922 #if defined (ACE_LACKS_LONGLONG_T)
01923 // No implementation available yet, no ACE_INT64 emulation
01924 // available yet
01925 #else /* ! ACE_LACKS_LONGLONG_T */
01926 {
01927 const ACE_TCHAR *fmt = ACE_INT64_FORMAT_SPECIFIER;
01928 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
01929 if (can_check)
01930 this_len = ACE_OS::snprintf (bp, bspace,
01931 format,
01932 va_arg (argp, ACE_INT64));
01933 else
01934 this_len = ACE_OS::sprintf (bp,
01935 format,
01936 va_arg (argp, ACE_INT64));
01937 }
01938 #endif /* ! ACE_LACKS_LONGLONG_T */
01939 ACE_UPDATE_COUNT (bspace, this_len);
01940 break;
01941
01942 case '@':
01943 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("p"));
01944 if (can_check)
01945 this_len = ACE_OS::snprintf
01946 (bp, bspace, format, va_arg (argp, void*));
01947 else
01948 this_len = ACE_OS::sprintf
01949 (bp, format, va_arg (argp, void*));
01950 ACE_UPDATE_COUNT (bspace, this_len);
01951 break;
01952
01953 default:
01954 // So, it's not a legit format specifier after all...
01955 // Copy from the original % to where we are now, then
01956 // continue with whatever comes next.
01957 while (start_format != format_str && bspace > 0)
01958 {
01959 *bp++ = *start_format++;
01960 --bspace;
01961 }
01962 if (bspace > 0)
01963 {
01964 *bp++ = *format_str;
01965 --bspace;
01966 }
01967 break;
01968 }
01969
01970 // Bump to the next char in the caller's format_str
01971 ++format_str;
01972 }
01973
01974 if (!skip_nul_locate)
01975 while (*bp != '\0') // Locate end of bp.
01976 ++bp;
01977 }
01978 }
01979
01980 *bp = '\0'; // Terminate bp, but don't auto-increment this!
01981
01982 ssize_t result = 0;
01983
01984 // Check that memory was not corrupted, if it corrupted we can't log anything
01985 // anymore because all our members could be corrupted.
01986 if (bp >= (this->msg_ + ACE_MAXLOGMSGLEN+1))
01987 {
01988 abort_prog = 1;
01989 ACE_OS::fprintf (stderr,
01990 "The following logged message is too long!\n");
01991 }
01992 else
01993 {
01994 // Copy the message from thread-specific storage into the transfer
01995 // buffer (this can be optimized away by changing other code...).
01996 log_record.msg_data (this->msg ());
01997
01998 // Write the <log_record> to the appropriate location.
01999 result = this->log (log_record,
02000 abort_prog);
02001 }
02002
02003 if (abort_prog)
02004 {
02005 // Since we are now calling abort instead of exit, this value is
02006 // not used.
02007 ACE_UNUSED_ARG (exit_value);
02008
02009 // *Always* print a message to stderr if we're aborting. We
02010 // don't use verbose, however, to avoid recursive aborts if
02011 // something is hosed.
02012 log_record.print (ACE_Log_Msg::local_host_, 0, stderr);
02013 ACE_OS::abort ();
02014 }
02015
02016 return result;
02017 }
|
|
||||||||||||||||
|
Since this is the ANTI_TCHAR version, we need to convert the format string over. Definition at line 954 of file Log_Msg.cpp. References ACE_ANTI_TCHAR, ACE_TEXT_ANTI_TO_TCHAR, ACE_TRACE, log(), and ssize_t.
00956 {
00957 ACE_TRACE ("ACE_Log_Msg::log");
00958
00959 // Start of variable args section.
00960 va_list argp;
00961
00962 va_start (argp, format_str);
00963
00964 ssize_t result = this->log (ACE_TEXT_ANTI_TO_TCHAR (format_str),
00965 log_priority,
00966 argp);
00967 va_end (argp);
00968
00969 return result;
00970 }
|
|
||||||||||||||||
|
Format a message to the thread-safe ACE logging mechanism. Valid options (prefixed by '%', as in printf format strings) include:
Definition at line 930 of file Log_Msg.cpp. References ACE_TCHAR, ACE_TRACE, and ssize_t. Referenced by __ace_assert(), log(), and log_hexdump().
|
|
||||||||||||||||||||
|
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 2162 of file Log_Msg.cpp. References ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_SIZE_T_FORMAT_SPECIFIER, ACE_TCHAR, log(), log_priority_enabled(), ACE_OS::sprintf(), and ACE_OS::strlen().
02166 {
02167 // Only print the message if <priority_mask_> hasn't been reset to
02168 // exclude this logging priority.
02169 if (this->log_priority_enabled (log_priority) == 0)
02170 return 0;
02171
02172 ACE_TCHAR* buf = 0;
02173 const size_t buf_sz =
02174 ACE_Log_Record::MAXLOGMSGLEN - ACE_Log_Record::VERBOSE_LEN - 58;
02175 ACE_NEW_RETURN (buf, ACE_TCHAR[buf_sz], -1);
02176
02177 ACE_TCHAR *msg_buf = 0;
02178 const size_t text_sz = text ? ACE_OS::strlen(text) : 0;
02179 ACE_NEW_RETURN (msg_buf,
02180 ACE_TCHAR[text_sz + 58],
02181 -1);
02182
02183 buf[0] = 0; // in case size = 0
02184
02185 const size_t len = ACE::format_hexdump
02186 (buffer, size, buf, buf_sz / sizeof (ACE_TCHAR) - text_sz);
02187
02188 int sz = 0;
02189
02190 if (text)
02191 sz = ACE_OS::sprintf (msg_buf,
02192 ACE_LIB_TEXT ("%s - "),
02193 text);
02194
02195 sz += ACE_OS::sprintf (msg_buf + sz,
02196 ACE_LIB_TEXT ("HEXDUMP ")
02197 ACE_SIZE_T_FORMAT_SPECIFIER
02198 ACE_LIB_TEXT (" bytes"),
02199 size);
02200
02201 if (len < size)
02202 ACE_OS::sprintf (msg_buf + sz,
02203 ACE_LIB_TEXT (" (showing first ")
02204 ACE_SIZE_T_FORMAT_SPECIFIER
02205 ACE_LIB_TEXT (" bytes)"),
02206 len);
02207
02208 // Now print out the formatted buffer.
02209 this->log (log_priority,
02210 ACE_LIB_TEXT ("%s\n%s"),
02211 msg_buf,
02212 buf);
02213
02214 delete [] msg_buf;
02215 delete [] buf;
02216 return 0;
02217 }
|
|
||||||||||||||||
|
Return true if the requested priority is enabled.
Definition at line 2567 of file Log_Msg.cpp. References log_priority_enabled().
02570 {
02571 return this->log_priority_enabled (log_priority);
02572 }
|
|
|
Return true if the requested priority is enabled.
Definition at line 628 of file Log_Msg.cpp. References ACE_BIT_ENABLED, and process_priority_mask_. Referenced by log(), log_hexdump(), and log_priority_enabled().
00629 {
00630 return ACE_BIT_ENABLED (this->priority_mask_ |
00631 ACE_Log_Msg::process_priority_mask_,
00632 log_priority);
00633 }
|
|
|
Get the message that describes what type of error occurred.
Definition at line 2458 of file Log_Msg.cpp. References msg_, and msg_off_. Referenced by log().
02459 {
02460 return this->msg_ + ACE_Log_Msg::msg_off_;
02461 }
|
|
|
Set the message that describes what type of error occurred.
Definition at line 2464 of file Log_Msg.cpp. References ACE_MAXLOGMSGLEN, ACE_TCHAR, and ACE_OS::strsncpy().
02465 {
02466 ACE_OS::strsncpy (this->msg_, m,
02467 ((ACE_MAXLOGMSGLEN+1) / sizeof (ACE_TCHAR)));
02468 }
|
|
|
Definition at line 2497 of file Log_Msg.cpp. References ACE_GUARD_RETURN, and ACE_TRACE.
02498 {
02499 ACE_TRACE ("ACE_Log_Msg::msg_backend");
02500 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
02501 *ACE_Log_Msg_Manager::get_lock (), 0));
02502
02503 return ACE_Log_Msg_Manager::custom_backend_;
02504 }
|
|
|
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 2485 of file Log_Msg.cpp. References ACE_GUARD_RETURN, and ACE_TRACE.
02486 {
02487 ACE_TRACE ("ACE_Log_Msg::msg_backend");
02488 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
02489 *ACE_Log_Msg_Manager::get_lock (), 0));
02490
02491 ACE_Log_Msg_Backend *tmp = ACE_Log_Msg_Manager::custom_backend_;
02492 ACE_Log_Msg_Manager::custom_backend_ = b;
02493 return tmp;
02494 }
|
|
|
Definition at line 2471 of file Log_Msg.cpp. References msg_callback_. Referenced by log(), and set().
02472 {
02473 return this->msg_callback_;
02474 }
|
|
|
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 2477 of file Log_Msg.cpp. References msg_callback_. Referenced by __ace_assert().
02478 {
02479 ACE_Log_Msg_Callback *old = this->msg_callback_;
02480 this->msg_callback_ = c;
02481 return old;
02482 }
|
|
|
Get the ostream that is used to print error messages.
Definition at line 2507 of file Log_Msg.cpp. References ostream_. Referenced by log(), open(), and set().
02508 {
02509 return this->ostream_;
02510 }
|
|
||||||||||||
|
delete_stream == 1, 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 2513 of file Log_Msg.cpp. References delete_ostream_, ACE_OS::fclose(), and ostream_.
02514 {
02515 if (this->ostream_ == m)
02516 return;
02517
02518 if (this->delete_ostream_)
02519 {
02520 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
02521 ACE_OS::fclose (this->ostream_);
02522 #else
02523 delete this->ostream_;
02524 #endif
02525 }
02526
02527 this->delete_ostream_ = delete_ostream;
02528 this->ostream_ = m;
02529 }
|
|
|
Update the ostream without overwriting the delete_ostream_ flag.
Definition at line 2532 of file Log_Msg.cpp. References ostream_. Referenced by __ace_assert(), ACE_Logging_Strategy::handle_timeout(), inherit_hook(), ACE_Logging_Strategy::init(), and init_hook().
02533 {
02534 this->ostream_ = m;
02535 }
|
|
|
Get the result of the operation status (by convention, -1 means error). Definition at line 2305 of file Log_Msg.cpp. References status_. Referenced by log(), and set().
02306 {
02307 return this->status_;
02308 }
|
|
|
Set the result of the operation status (by convention, -1 means error). Definition at line 2299 of file Log_Msg.cpp. References status_.
02300 {
02301 this->status_ = status;
02302 }
|
|
||||||||||||||||
|
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.
Definition at line 768 of file Log_Msg.cpp. References ACE_ALLOCATOR_RETURN, ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_NO_HEAP_CHECK, ACE_SET_BITS, ACE_TCHAR, ACE_TRACE, CUSTOM, flags_, ACE_OS::free(), LOGGER, MSG_CALLBACK, msg_ostream(), ACE_Log_Msg_Backend::open(), OSTREAM, program_name_, ACE_Log_Msg_Backend::reset(), SILENT, STDERR, SYSLOG, VERBOSE, and VERBOSE_LITE. Referenced by ACE_Logging_Strategy::init(), and ACE_Service_Config::open_i().
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_LIB_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 }
|
|
|
|
|
||||||||||||
|
Set the ACE_Log_Priority mask, returns original mask.
Definition at line 601 of file Log_Msg.cpp. References priority_mask_, process_priority_mask_, and THREAD.
00602 {
00603 u_long o_mask;
00604
00605 if (mask_type == THREAD)
00606 {
00607 o_mask = this->priority_mask_;
00608 this->priority_mask_ = n_mask;
00609 }
00610 else
00611 {
00612 o_mask = ACE_Log_Msg::process_priority_mask_;
00613 ACE_Log_Msg::process_priority_mask_ = n_mask;
00614 }
00615
00616 return o_mask;
00617 }
|
|
|
Get the current ACE_Log_Priority mask.
Definition at line 620 of file Log_Msg.cpp. References priority_mask_, process_priority_mask_, and THREAD. Referenced by disable_debug_messages(), enable_debug_messages(), inherit_hook(), ACE_Logging_Strategy::init(), init_hook(), and ACE_Service_Gestalt::open_i().
00621 {
00622 return mask_type == THREAD
00623 ? this->priority_mask_
00624 : ACE_Log_Msg::process_priority_mask_;
00625 }
|
|
|
Returns the current program name used for logging.
Definition at line 415 of file Log_Msg.cpp. References program_name_. Referenced by ACE_Log_Msg_UNIX_Syslog::open(), and ACE_Log_Msg_NT_Event_Log::open().
00416 {
00417 return ACE_Log_Msg::program_name_;
00418 }
|
|
|
Release the internal lock.
Definition at line 636 of file Log_Msg.cpp. References ACE_TRACE, and ACE_Recursive_Thread_Mutex::release(). Referenced by ACE_Logging_Strategy::handle_timeout().
00637 {
00638 ACE_TRACE ("ACE_Log_Msg::release");
00639
00640 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00641 return ACE_Log_Msg_Manager::get_lock ()->release ();
00642 #else /* ! ACE_MT_SAFE */
00643 return 0;
00644 #endif /* ! ACE_MT_SAFE */
00645 }
|
|
|
Get the field that indicates whether interrupted calls should be restarted. Definition at line 2317 of file Log_Msg.cpp. Referenced by set().
02318 {
02319 return this->restart_;
02320 }
|
|
|
Set the field that indicates whether interrupted calls should be restarted. Definition at line 2311 of file Log_Msg.cpp. Referenced by __ace_assert(), inherit_hook(), and init_hook().
02312 {
02313 this->restart_ = r;
02314 }
|
|
||||||||||||||||||||||||||||||||
|
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 2220 of file Log_Msg.cpp. References ACE_TRACE, errnum(), file(), linenum(), msg_callback(), msg_ostream(), op_status(), and restart(). Referenced by __ace_assert(), and log().
02227 {
02228 ACE_TRACE ("ACE_Log_Msg::set");
02229 this->file (filename);
02230 this->linenum (line);
02231 this->op_status (status);
02232 this->errnum (err);
02233 this->restart (rs);
02234 this->msg_ostream (os);
02235 this->msg_callback (c);
02236 }
|
|
|
Enable the bits in the logger's options flags. Definition at line 570 of file Log_Msg.cpp. References ACE_GUARD, ACE_SET_BITS, ACE_TRACE, and flags_. Referenced by ACE_Logging_Strategy::init().
00571 {
00572 ACE_TRACE ("ACE_Log_Msg::set_flags");
00573 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00574 *ACE_Log_Msg_Manager::get_lock ()));
00575
00576 ACE_SET_BITS (ACE_Log_Msg::flags_, flgs);
00577 }
|
|
|
Start tracing status on a per-thread basis...
Definition at line 2426 of file Log_Msg.cpp. References tracing_enabled_. Referenced by inherit_hook(), and log().
02427 {
02428 this->tracing_enabled_ = 1;
02429 }
|
|
|
Stop tracing status on a per-thread basis...
Definition at line 2434 of file Log_Msg.cpp. References tracing_enabled_. Referenced by log().
02435 {
02436 this->tracing_enabled_ = 0;
02437 }
|
|
|
Call after doing a Definition at line 534 of file Log_Msg.cpp. References ACE_NO_HEAP_CHECK, ACE_TCHAR, ACE_TRACE, ACE_OS::free(), ACE_OS::getpid(), msg_off_, pid_, program_name_, and ACE_OS::strdup().
00535 {
00536 ACE_TRACE ("ACE_Log_Msg::sync");
00537
00538 if (prog_name)
00539 {
00540 // Must free if already allocated!!!
00541 ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
00542
00543 // Stop heap checking, block will be freed by the destructor when
00544 // the last ACE_Log_Msg instance is deleted.
00545 // Heap checking state will be restored when the block is left.
00546 {
00547 ACE_NO_HEAP_CHECK;
00548
00549 ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name);
00550 }
00551 }
00552
00553 ACE_Log_Msg::pid_ = ACE_OS::getpid ();
00554 ACE_Log_Msg::msg_off_ = 0;
00555 }
|
|
|
Decouple the OS layer from the ACE_Log_Msg layer.
Definition at line 520 of file Log_Msg.cpp. References ACE_LOG_MSG, and ACE_TCHAR. Referenced by ACE_Log_Msg().
00521 {
00522 ACE_LOG_MSG->sync (prg_name);
00523 }
|
|
|
Set the TSS thread descriptor. This method will call td->acquire_release to block execution until this call return. Definition at line 2389 of file Log_Msg.cpp. References ACE_Thread_Descriptor::acquire_release().
02390 {
02391 this->thr_desc_ = td;
02392
02393 if (td != 0)
02394 td->acquire_release ();
02395 }
|
|
|
Get the TSS thread descriptor.
Definition at line 2383 of file Log_Msg.cpp. Referenced by inherit_hook().
02384 {
02385 return this->thr_desc_;
02386 }
|
|
|
Return the TSS singleton thread descriptor.
Definition at line 526 of file Log_Msg.cpp. References ACE_LOG_MSG. Referenced by ACE_Log_Msg().
00527 {
00528 return ACE_LOG_MSG->thr_desc ();
00529 }
|
|
|
Get trace active status.
Definition at line 2377 of file Log_Msg.cpp. References trace_active_.
02378 {
02379 this->trace_active_ = value;
02380 }
|
|
|
Set trace active status.
Definition at line 2371 of file Log_Msg.cpp. References trace_active_. Referenced by ACE_Trace::ACE_Trace(), and ACE_Trace::~ACE_Trace().
02372 {
02373 return this->trace_active_;
02374 }
|
|
|
Set trace depth.
Definition at line 2365 of file Log_Msg.cpp. References trace_depth_.
02366 {
02367 this->trace_depth_ = depth;
02368 }
|
|
|
Get trace depth.
Definition at line 2359 of file Log_Msg.cpp. References trace_depth_. Referenced by inherit_hook(), and init_hook().
02360 {
02361 return this->trace_depth_;
02362 }
|
|
|
Query tracing status on a per-thread basis...
Definition at line 2440 of file Log_Msg.cpp. References tracing_enabled_. Referenced by ACE_Trace::ACE_Trace(), init_hook(), log(), and ACE_Trace::~ACE_Trace().
02441 {
02442 return this->tracing_enabled_;
02443 }
|
|
|
Declare the dynamic allocation hooks.
|
|
|
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. Referenced by ACE_Log_Msg(), conditional_set(), and log(). |
|
|
Priority mask to use for each new instance Definition at line 437 of file Log_Msg.cpp. Referenced by disable_debug_messages(), and enable_debug_messages(). |
|
|
Are we deleting this ostream?
Definition at line 605 of file Log_Msg.h. Referenced by msg_ostream(), and ~ACE_Log_Msg(). |
|
|
Type of error that occurred (see <sys/errno.h>).
Definition at line 672 of file Log_Msg.h. Referenced by errnum(). |
|
|
|
|
|
File where the error occurred.
|
|
|
Default is to use stderr. Options flags used to hold the logger flag options, e.g., STDERR, LOGGER, OSTREAM, MSG_CALLBACK, etc. Definition at line 427 of file Log_Msg.cpp. Referenced by clr_flags(), flags(), log(), open(), and set_flags(). |
|
|
Number of existing ACE_Log_Msg instances; when 0, delete program/host names Definition at line 94 of file Log_Msg.cpp. Referenced by ACE_Log_Msg(), and ~ACE_Log_Msg(). |
|
|
|
|
|
|
|
|
Line number where the error occurred.
Definition at line 575 of file Log_Msg.h. Referenced by linenum(). |
|
|
Name of the local host (used when printing messages).
Definition at line 421 of file Log_Msg.cpp. Referenced by local_host(), log(), and ~ACE_Log_Msg(). |
|
|
The log message, which resides in thread-specific storage. Note that only the current log message is stored here -- it will be overwritten by the subsequent call to log(). Definition at line 583 of file Log_Msg.h. Referenced by log(), msg(), and ~ACE_Log_Msg(). |
|
|
The callback object.
Definition at line 593 of file Log_Msg.h. Referenced by msg_callback(). |
|
|
Offset of msg_[].
Definition at line 433 of file Log_Msg.cpp. |
|
|
|
|
|
The ostream where logging messages can be written.
Definition at line 590 of file Log_Msg.h. Referenced by msg_ostream(), and ~ACE_Log_Msg(). |
|
|
Process id of the current process.
Definition at line 430 of file Log_Msg.cpp. |
|
|
Keeps track of all the per-thread ACE_Log_Priority values that are currently enabled. Default is for all logging priorities to be disabled. Definition at line 620 of file Log_Msg.h. Referenced by priority_mask(). |
|
|
Initial value: LM_SHUTDOWN | LM_TRACE | LM_DEBUG | LM_INFO | LM_NOTICE | LM_WARNING | LM_STARTUP | LM_ERROR | LM_CRITICAL | LM_ALERT | LM_EMERGENCY Definition at line 441 of file Log_Msg.cpp. Referenced by log_priority_enabled(), and priority_mask(). |
|
|
Records the program name.
Definition at line 424 of file Log_Msg.cpp. Referenced by log(), open(), program_name(), sync(), and ~ACE_Log_Msg(). |
|
|
Indicates whether we should restart system calls that are interrupted. |
|
|
Status of operation (-1 means failure, >= 0 means success).
Definition at line 569 of file Log_Msg.h. Referenced by op_status(). |
|
|
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. |
|
|
Always timestamp?
Definition at line 623 of file Log_Msg.h. Referenced by ACE_Log_Msg(), and log(). |
|
|
Are we already within an ACE_Trace constructor call?
Definition at line 599 of file Log_Msg.h. Referenced by trace_active(). |
|
|
Depth of the nesting for printing traces.
Definition at line 596 of file Log_Msg.h. Referenced by dec(), inc(), log(), and trace_depth(). |
|
|
Are we allowing tracing in this thread?
Definition at line 602 of file Log_Msg.h. Referenced by start_tracing(), stop_tracing(), and tracing_enabled(). |
1.3.6