#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 Methods | |
| ACE_Log_Msg (void) | |
| Initialize logger. More... | |
| ~ACE_Log_Msg (void) | |
| cleanup logger. More... | |
| 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. More... | |
| void | set_flags (u_long f) |
| void | clr_flags (u_long f) |
| u_long | flags (void) |
| void | sync (const ACE_TCHAR *program_name) |
Call after doing a fork() to resynchronize the process id and program_name_ variables. More... | |
| void | op_status (int status) |
| Set the result of the operation status (by convention, -1 means error). More... | |
| int | op_status (void) |
| Get the result of the operation status (by convention, -1 means error). More... | |
| void | errnum (int) |
| Set the value of the errnum (by convention this corresponds to errno). More... | |
| int | errnum (void) |
| Get the value of the errnum (by convention this corresponds to errno). More... | |
| void | linenum (int) |
| Set the line number where an error occurred. More... | |
| int | linenum (void) |
| Get the line number where an error occurred. More... | |
| void | file (const char *) |
| Set the file name where an error occurred. More... | |
| const char * | file (void) |
| Get the file name where an error occurred. More... | |
| void | msg (const ACE_TCHAR *) |
| Set the message that describes what type of error occurred. More... | |
| const ACE_TCHAR * | msg (void) |
| Get the message that describes what type of error occurred. More... | |
| void | restart (int) |
| Set the field that indicates whether interrupted calls should be restarted. More... | |
| int | restart (void) |
| Get the field that indicates whether interrupted calls should be restarted. More... | |
| void | msg_ostream (ACE_OSTREAM_TYPE *) |
| Update the ostream without overwriting the delete_ostream_ flag. More... | |
| 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. More... | |
| 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. More... | |
| int | dec (void) |
| Nesting depth decrement. More... | |
| int | trace_depth (void) |
| Get trace depth. More... | |
| void | trace_depth (int) |
| Set trace depth. More... | |
| int | trace_active (void) |
| Set trace active status. More... | |
| void | trace_active (int value) |
| Get trace active status. More... | |
| ACE_Thread_Descriptor * | thr_desc (void) const |
| Get the TSS thread descriptor. More... | |
| void | thr_desc (ACE_Thread_Descriptor *td) |
| void | stop_tracing (void) |
| Stop tracing status on a per-thread basis... More... | |
| void | start_tracing (void) |
| Start tracing status on a per-thread basis... More... | |
| int | tracing_enabled (void) |
| Query tracing status on a per-thread basis... More... | |
| u_long | priority_mask (MASK_TYPE=THREAD) |
| Get the current ACE_Log_Priority mask. More... | |
| u_long | priority_mask (u_long, MASK_TYPE=THREAD) |
| Set the ACE_Log_Priority mask, returns original mask. More... | |
| int | log_priority_enabled (ACE_Log_Priority log_priority) |
| Return true if the requested priority is enabled. More... | |
| int | log_priority_enabled (ACE_Log_Priority log_priority, const char *,...) |
| Return true if the requested priority is enabled. More... | |
| pid_t | getpid (void) const |
| Optimize reading of the pid (avoids a system call if the value is cached...). More... | |
| const ACE_TCHAR * | local_host (void) const |
| Get the name of the local host. More... | |
| void | local_host (const ACE_TCHAR *) |
| Set the name of the local host. More... | |
| 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) |
| These values are only actually set if the requested priority is enabled. More... | |
| 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) |
| Log a custom built log record to the currently enabled logging sinks. More... | |
| 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. More... | |
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. More... | |
| int | release (void) |
| Release the internal lock. More... | |
Static Public Methods | |
| ACE_Log_Msg * | instance (void) |
| Returns a pointer to the Singleton. More... | |
| int | last_error_adapter (void) |
| Returns last error. More... | |
| int | exists (void) |
| Returns non-null if an ACE_Log_Msg exists for the calling thread. More... | |
| const ACE_TCHAR * | program_name (void) |
| Returns the current program name used for logging. More... | |
| void | disable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances. More... | |
| void | enable_debug_messages (ACE_Log_Priority priority=LM_DEBUG) |
| Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances. More... | |
| 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. More... | |
Private Methods | |
| ACE_Log_Msg & | operator= (const ACE_Log_Msg &) |
| ACE_Log_Msg (const ACE_Log_Msg &) | |
Static Private Methods | |
| void | close (void) |
| For cleanup, at program termination. More... | |
| void | sync_hook (const ACE_TCHAR *prg_name) |
| Decouple the OS layer from the ACE_Log_Msg layer. More... | |
| ACE_OS_Thread_Descriptor * | thr_desc_hook (void) |
| Return the TSS singleton thread descriptor. More... | |
Private Attributes | |
| int | status_ |
| Status of operation (-1 means failure, >= 0 means success). More... | |
| int | errnum_ |
| Type of error that occurred (see <sys/errno.h>). More... | |
| int | linenum_ |
| Line number where the error occurred. More... | |
| char | file_ [MAXPATHLEN+1] |
| File where the error occurred. More... | |
| ACE_TCHAR | msg_ [ACE_MAXLOGMSGLEN+1] |
| 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(). More... | |
| int | restart_ |
| Indicates whether we should restart system calls that are interrupted. More... | |
| ACE_OSTREAM_TYPE * | ostream_ |
| The ostream where logging messages can be written. More... | |
| ACE_Log_Msg_Callback * | msg_callback_ |
| The callback object. More... | |
| int | trace_depth_ |
| Depth of the nesting for printing traces. More... | |
| int | trace_active_ |
| Are we already within an ACE_Trace constructor call? More... | |
| int | tracing_enabled_ |
| Are we allowing tracing in this thread? More... | |
| int | delete_ostream_ |
| Are we deleting this ostream? More... | |
| ACE_Thread_Descriptor * | thr_desc_ |
| u_long | priority_mask_ |
| struct { | |
| int is_set_ | |
| const char * file_ | |
| int line_ | |
| int op_status_ | |
| int errnum_ | |
| } | conditional_values_ |
| 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. More... | |
Static Private Attributes | |
| u_long | process_priority_mask_ |
| Default per-process priority mask By default, all priorities are enabled. More... | |
| const ACE_TCHAR * | program_name_ = 0 |
| Records the program name. More... | |
| const ACE_TCHAR * | local_host_ = 0 |
| Name of the local host (used when printing messages). More... | |
| pid_t | pid_ = -1 |
| Process id of the current process. More... | |
| u_long | flags_ = ACE_Log_Msg::STDERR |
| Options flags used to hold the logger flag options, e.g., STDERR, LOGGER, OSTREAM, MSG_CALLBACK, etc. More... | |
| int | msg_off_ = 0 |
| Offset of msg_[]. More... | |
| int | instance_count_ = 0 |
| Instance count for Log_Msg - used to know when dynamically allocated storage (program name and host name) can be safely deleted. More... | |
| u_long | default_priority_mask_ = 0 |
| Default per-thread priority mask By default, no priorities are enabled. More... | |
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 154 of file Log_Msg.h.
|
|
Definition at line 159 of file Log_Msg.h.
00160 {
00161 /// Write messages to stderr.
00162 STDERR = 1,
00163 /// Write messages to the local client logger deamon.
00164 LOGGER = 2,
00165 /// Write messages to the ostream * stored in thread-specific
00166 /// storage.
00167 OSTREAM = 4,
00168 /// Write messages to the callback object.
00169 MSG_CALLBACK = 8,
00170 /// Display messages in a verbose manner.
00171 VERBOSE = 16,
00172 /// Display messages in a less verbose manner (i.e., only print
00173 /// information that can change between calls).
00174 VERBOSE_LITE = 32,
00175 /// Do not print messages at all (just leave in thread-specific
00176 /// storage for later inspection).
00177 SILENT = 64,
00178 /// Write messages to the system's event log.
00179 SYSLOG = 128,
00180 /// Write messages to the user provided backend
00181 CUSTOM = 256
00182 };
|
|
|
Definition at line 409 of file Log_Msg.h. Referenced by ACE_Logging_Strategy::priorities.
|
|
|
|
cleanup logger.
Definition at line 640 of file Log_Msg.cpp. References ACE_GUARD, ACE_MT, ACE_Log_Msg_Backend::close, ACE_Log_Msg_Manager::custom_backend_, delete_ostream_, ACE_OS::fclose, ACE_OS_Memory::free, instance_count_, local_host_, ACE_Log_Msg_Manager::log_backend_, ostream_, and program_name_.
00641 {
00642 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00643
00644 int instance_count;
00645
00646 // Only hold the guard while updating the instance_count_.
00647 // If ACE_Log_Msg_Manager::close () is called, the lock will
00648 // be deleted.
00649 {
00650 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00651 *ACE_Log_Msg_Manager::get_lock ()));
00652 instance_count = --instance_count_;
00653 }
00654 // Release the guard.
00655
00656 #else /* ! ACE_MT_SAFE */
00657 int instance_count = --instance_count_;
00658 #endif /* ! ACE_MT_SAFE */
00659
00660 // If this is the last instance then cleanup. Only the last
00661 // thread to destroy its ACE_Log_Msg instance should execute
00662 // this block.
00663 if (instance_count == 0)
00664 {
00665 // Destroy the message queue instance.
00666 if (ACE_Log_Msg_Manager::log_backend_ != 0)
00667 ACE_Log_Msg_Manager::log_backend_->close ();
00668
00669 // Close down custom backend
00670 if (ACE_Log_Msg_Manager::custom_backend_ != 0)
00671 ACE_Log_Msg_Manager::custom_backend_->close ();
00672
00673 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00674 # if defined (ACE_HAS_TSS_EMULATION)
00675 ACE_Log_Msg_Manager::close ();
00676 # endif /* ACE_HAS_TSS_EMULATION */
00677 # endif /* ACE_MT_SAFE */
00678
00679 if (ACE_Log_Msg::program_name_)
00680 {
00681 ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
00682 ACE_Log_Msg::program_name_ = 0;
00683 }
00684
00685 if (ACE_Log_Msg::local_host_)
00686 {
00687 ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
00688 ACE_Log_Msg::local_host_ = 0;
00689 }
00690 }
00691
00692 //
00693 // do we need to close and clean up?
00694 //
00695 if (this->delete_ostream_ == 1)
00696 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
00697 {
00698 ACE_OS::fclose (this->ostream_);
00699 }
00700 #else
00701 {
00702 delete ostream_;
00703 }
00704 #endif
00705 }
|
|
|
|
|
|
Acquire the internal lock.
Definition at line 556 of file Log_Msg.cpp. References ACE_TRACE, and ACE_Recursive_Thread_Mutex::acquire. Referenced by ACE_Logging_Strategy::handle_timeout.
00557 {
00558 ACE_TRACE ("ACE_Log_Msg::acquire");
00559 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00560 return ACE_Log_Msg_Manager::get_lock ()->acquire ();
00561 #else /* ! ACE_MT_SAFE */
00562 return 0;
00563 #endif /* ! ACE_MT_SAFE */
00564 }
|
|
|
For cleanup, at program termination.
Definition at line 443 of file Log_Msg.cpp. References ACE_MT, ACE_OS_Object_Manager::preallocated_object, ACE_OS_Object_Manager::shutting_down, ACE_OS::thread_mutex_lock, and ACE_OS::thread_mutex_unlock. Referenced by ACE_Log_Msg.
00444 {
00445 // This call needs to go here to avoid memory leaks.
00446 ACE_MT (ACE_Log_Msg_Manager::close ());
00447
00448 // Please note that this will be called by a statement that is
00449 // harded coded into the ACE_Object_Manager's shutdown sequence, in
00450 // its destructor.
00451
00452 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && \
00453 (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00454 defined (ACE_HAS_TSS_EMULATION))
00455
00456 if (key_created_ == 1)
00457 {
00458 ACE_thread_mutex_t *lock =
00459 ACE_reinterpret_cast (ACE_thread_mutex_t *,
00460 ACE_OS_Object_Manager::preallocated_object
00461 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
00462
00463 if (!ACE_OS_Object_Manager::shutting_down ())
00464 ACE_OS::thread_mutex_lock (lock);
00465
00466 if (key_created_ == 1)
00467 {
00468 // The same as the ACE_TSS_Cleanup's own key doesn't get
00469 // detached, the log_msg_tss_key_ won't get detached
00470 // until ACE_TSS_Cleanup::free_all_keys_left, so it will
00471 // be in the ACE_TSS_Cleanup::table_. However, there's
00472 // no resource associated with it, so we don't need to
00473 // keyfree it. The dynamic memory associated with it was
00474 // already deleted by ACE_TSS_Cleanup::exit (), so we
00475 // don't want to access it again.
00476 key_created_ = 0;
00477 }
00478
00479 if (!ACE_OS_Object_Manager::shutting_down ())
00480 ACE_OS::thread_mutex_unlock (lock);
00481 }
00482 #endif /* (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) && ACE_MT_SAFE */
00483 }
|
|
|
Disable the bits in the logger's options flags. Definition at line 546 of file Log_Msg.cpp. References ACE_CLR_BITS, ACE_GUARD, ACE_MT, ACE_TRACE, and flags_. Referenced by ACE_Logging_Strategy::init.
00547 {
00548 ACE_TRACE ("ACE_Log_Msg::clr_flags");
00549 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00550 *ACE_Log_Msg_Manager::get_lock ()));
00551
00552 ACE_CLR_BITS (ACE_Log_Msg::flags_, flgs);
00553 }
|
|
||||||||||||||||||||
|
These values are only actually set if the requested priority is enabled.
Definition at line 2118 of file Log_Msg.cpp. References conditional_values_.
02122 {
02123 this->conditional_values_.is_set_ = 1;
02124 this->conditional_values_.file_ = filename;
02125 this->conditional_values_.line_ = line;
02126 this->conditional_values_.op_status_ = status;
02127 this->conditional_values_.errnum_ = err;
02128 }
|
|
|
Nesting depth decrement.
Definition at line 2230 of file Log_Msg.cpp. References trace_depth_. Referenced by log, and ACE_Trace::~ACE_Trace.
02231 {
02232 return --this->trace_depth_;
02233 }
|
|
|
Clears the flag from the default priority mask used to initialize ACE_Log_Msg instances.
Definition at line 396 of file Log_Msg.cpp. References ACE_CLR_BITS, ACE_Log_Priority, default_priority_mask_, instance, and priority_mask. Referenced by ACE_Service_Config::fini_svcs, and ACE_Service_Config::open_i.
00397 {
00398 ACE_CLR_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 }
|
|
|
Dump the state of an object.
Definition at line 2131 of file Log_Msg.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_MT, ACE_TRACE, dump, ACE_Log_Msg_Manager::init_backend, LM_DEBUG, ACE_Thread_Descriptor_Base::state, and thr_desc_. Referenced by dump.
02132 {
02133 ACE_TRACE ("ACE_Log_Msg::dump");
02134
02135 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02136 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("status_ = %d\n"), this->status_));
02137 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nerrnum_ = %d\n"), this->errnum_));
02138 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlinenum_ = %d\n"), this->linenum_));
02139 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfile_ = %s\n"), this->file_));
02140 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_ = %s\n"), this->msg_));
02141 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nrestart_ = %d\n"), this->restart_));
02142 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nostream_ = %x\n"), this->ostream_));
02143 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_callback_ = %x\n"),
02144 this->msg_callback_));
02145 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nprogram_name_ = %s\n"),
02146 this->program_name_ ? this->program_name_
02147 : ACE_LIB_TEXT ("<unknown>")));
02148 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlocal_host_ = %s\n"),
02149 this->local_host_ ? this->local_host_
02150 : ACE_LIB_TEXT ("<unknown>")));
02151 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %d\n"), this->getpid ()));
02152 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nflags_ = %x\n"), this->flags_));
02153 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_depth_ = %d\n"),
02154 this->trace_depth_));
02155 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_active_ = %d\n"),
02156 this->trace_active_));
02157 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntracing_enabled_ = %d\n"),
02158 this->tracing_enabled_));
02159 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npriority_mask_ = %x\n"),
02160 this->priority_mask_));
02161 if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0)
02162 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nthr_state_ = %d\n"),
02163 this->thr_desc_->state ()));
02164 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_off_ = %d\n"), this->msg_off_));
02165
02166 // Be sure that there is a message_queue_, with multiple threads.
02167 ACE_MT (ACE_Log_Msg_Manager::init_backend ());
02168
02169 ACE_MT (ACE_Log_Msg_Manager::get_lock ()->dump ());
02170 // Synchronize output operations.
02171
02172 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02173 }
|
|
|
Sets the flag in the default priority mask used to initialize ACE_Log_Msg instances.
Definition at line 385 of file Log_Msg.cpp. References ACE_Log_Priority, ACE_SET_BITS, default_priority_mask_, instance, and priority_mask. Referenced by ACE_Service_Config::fini_svcs, and ACE_Service_Config::open_i.
00386 {
00387 ACE_SET_BITS (ACE_Log_Msg::default_priority_mask_, priority);
00388 ACE_Log_Msg *i = ACE_Log_Msg::instance ();
00389 i->priority_mask (i->priority_mask () | priority);
00390 }
|
|
|
Get the value of the errnum (by convention this corresponds to errno).
Definition at line 2200 of file Log_Msg.cpp. References errnum_. Referenced by set.
02201 {
02202 return this->errnum_;
02203 }
|
|
|
Set the value of the errnum (by convention this corresponds to errno).
Definition at line 2206 of file Log_Msg.cpp. References errnum_.
02207 {
02208 this->errnum_ = e;
02209 }
|
|
|
Returns non-null if an ACE_Log_Msg exists for the calling thread.
Definition at line 238 of file Log_Msg.cpp. References ACE_Thread::getspecific. Referenced by init_hook.
00239 {
00240 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00241 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00242 defined (ACE_HAS_TSS_EMULATION)
00243 ACE_Log_Msg *tss_log_msg = 0;
00244
00245 // Get the tss_log_msg from thread-specific storage.
00246 return key_created_
00247 && ACE_Thread::getspecific (log_msg_tss_key_,
00248 ACE_reinterpret_cast (void **,
00249 &tss_log_msg)) != -1
00250 && tss_log_msg;
00251 # else
00252 # error "Platform must support thread-specific storage if threads are used."
00253 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
00254 #else /* ! ACE_MT_SAFE */
00255 return 1;
00256 #endif /* ! ACE_MT_SAFE */
00257 }
|
|
|
Get the file name where an error occurred.
Definition at line 2323 of file Log_Msg.cpp. References file_. Referenced by set.
02324 {
02325 return this->file_;
02326 }
|
|
|
Set the file name where an error occurred.
Definition at line 2329 of file Log_Msg.cpp. References ACE_OS_String::strsncpy.
02330 {
02331 ACE_OS::strsncpy (this->file_, s, sizeof this->file_);
02332 }
|
|
|
Return the bits in the logger's options flags. Definition at line 524 of file Log_Msg.cpp. References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, and flags_. Referenced by open, and ACE_Service_Config::open_i.
00525 {
00526 ACE_TRACE ("ACE_Log_Msg::flags");
00527 u_long result;
00528 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00529 *ACE_Log_Msg_Manager::get_lock (), 0));
00530
00531 result = ACE_Log_Msg::flags_;
00532 return result;
00533 }
|
|
|
Optimize reading of the pid (avoids a system call if the value is cached...).
Definition at line 2423 of file Log_Msg.cpp. References ACE_OS::getpid, and pid_.
02424 {
02425 if (ACE_Log_Msg::pid_ == -1)
02426 ACE_Log_Msg::pid_ = ACE_OS::getpid ();
02427
02428 return ACE_Log_Msg::pid_;
02429 }
|
|
|
Nesting depth increment.
Definition at line 2224 of file Log_Msg.cpp. References trace_depth_. Referenced by ACE_Trace::ACE_Trace, and log.
02225 {
02226 return this->trace_depth_++;
02227 }
|
|
||||||||||||
|
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 2483 of file Log_Msg.cpp. References ACE_DEBUG, ACE_LIB_TEXT, ACE_LOG_MSG, LM_DEBUG, MAXPATHLEN, msg_ostream, open, ACE_OS_Log_Msg_Attributes::ostream_, priority_mask, ACE_OS_Log_Msg_Attributes::priority_mask_, restart, ACE_OS_Log_Msg_Attributes::restart_, start_tracing, ACE_OS_String::strcat, 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.
02485 {
02486 #if !defined (ACE_THREADS_DONT_INHERIT_LOG_MSG) && \
02487 !defined (ACE_HAS_MINIMAL_ACE_OS)
02488 // Inherit the logging features if the parent thread has an
02489 // <ACE_Log_Msg>. Note that all of the following operations occur
02490 // within thread-specific storage.
02491 ACE_Log_Msg *new_log = ACE_LOG_MSG;
02492
02493 // Note that we do not inherit the callback because this might have
02494 // been allocated off of the stack of the original thread, in which
02495 // case all hell would break loose...
02496
02497 if (attributes.ostream_)
02498 {
02499 new_log->msg_ostream (attributes.ostream_);
02500 new_log->priority_mask (attributes.priority_mask_);
02501
02502 if (attributes.tracing_enabled_)
02503 new_log->start_tracing ();
02504
02505 new_log->restart (attributes.restart_);
02506 new_log->trace_depth (attributes.trace_depth_);
02507 }
02508
02509 // @@ Now the TSS Log_Msg has been created, cache my thread
02510 // descriptor in.
02511
02512 if (thr_desc != 0)
02513 // This downcast is safe. We do it to avoid having to #include
02514 // ace/Thread_Manager.h.
02515 new_log->thr_desc (ACE_static_cast (ACE_Thread_Descriptor *,
02516 thr_desc));
02517 // Block the thread from proceeding until
02518 // thread manager has thread descriptor ready.
02519
02520 # else /* Don't inherit Log Msg */
02521 # if defined (ACE_PSOS)
02522 //Create a special name for each thread...
02523 char new_name[MAXPATHLEN]={"Ace_thread-"};
02524 char new_id[2]={0,0}; //Now it's pre-terminated!
02525
02526 new_id[0] = '0' + (ACE_PSOS_unique_file_id++); //Unique identifier
02527 ACE_OS::strcat(new_name, new_id);
02528
02529 //Initialize the task specific logger
02530 ACE_LOG_MSG->open(new_name);
02531 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%P|%t) starting %s thread at %D\n"),new_name));
02532 # endif /* ACE_PSOS */
02533 #endif /* ! ACE_THREADS_DONT_INHERIT_LOG_MSG && ! ACE_HAS_MINIMAL_ACE_OS */
02534 }
|
|
|
Definition at line 2452 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.
02458 {
02459 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
02460 attributes.seh_except_selector_ = selector;
02461 attributes.seh_except_handler_ = handler;
02462 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
02463 if (ACE_Log_Msg::exists ())
02464 {
02465 ACE_Log_Msg *inherit_log = ACE_LOG_MSG;
02466 attributes.ostream_ = inherit_log->msg_ostream ();
02467 attributes.priority_mask_ = inherit_log->priority_mask ();
02468 attributes.tracing_enabled_ = inherit_log->tracing_enabled ();
02469 attributes.restart_ = inherit_log->restart ();
02470 attributes.trace_depth_ = inherit_log->trace_depth ();
02471 }
02472 }
|
|
|
Returns a pointer to the Singleton.
Definition at line 260 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::object, ACE_OS_Object_Manager::preallocated_object, ACE_Thread::setspecific, ACE_OS_Object_Manager::starting_up, ACE_OS::thread_mutex_lock, and ACE_OS::thread_mutex_unlock. Referenced by disable_debug_messages, and enable_debug_messages.
00261 {
00262 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00263 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
00264 defined (ACE_HAS_TSS_EMULATION)
00265 // TSS Singleton implementation.
00266
00267 if (key_created_ == 0)
00268 {
00269 ACE_thread_mutex_t *lock =
00270 ACE_reinterpret_cast (ACE_thread_mutex_t *,
00271 ACE_OS_Object_Manager::preallocated_object
00272 [ACE_OS_Object_Manager::ACE_LOG_MSG_INSTANCE_LOCK]);
00273
00274 if (1 == ACE_OS_Object_Manager::starting_up())
00275 //This function is called before ACE_OS_Object_Manager is
00276 //initialized. So the lock might not be valid. Assume it's
00277 //single threaded and so don't need the lock.
00278 ;
00279 else
00280 ACE_OS::thread_mutex_lock (lock);
00281
00282 if (key_created_ == 0)
00283 {
00284 // Allocate the Singleton lock.
00285 ACE_Log_Msg_Manager::get_lock ();
00286
00287 {
00288 ACE_NO_HEAP_CHECK;
00289 if (ACE_Thread::keycreate (&log_msg_tss_key_,
00290 &ACE_TSS_cleanup) != 0)
00291 {
00292 if (1 == ACE_OS_Object_Manager::starting_up())
00293 //This function is called before ACE_OS_Object_Manager is
00294 //initialized. So the lock might not be valid. Assume it's
00295 //single threaded and so don't need the lock.
00296 ;
00297 else
00298 ACE_OS::thread_mutex_unlock (lock);
00299 return 0; // Major problems, this should *never* happen!
00300 }
00301 }
00302
00303 key_created_ = 1;
00304 }
00305
00306 if (1 == ACE_OS_Object_Manager::starting_up())
00307 //This function is called before ACE_OS_Object_Manager is
00308 //initialized. So the lock might not be valid. Assume it's
00309 //single threaded and so don't need the lock.
00310 ;
00311 else
00312 ACE_OS::thread_mutex_unlock (lock);
00313 }
00314
00315 ACE_Log_Msg *tss_log_msg = 0;
00316
00317 // Get the tss_log_msg from thread-specific storage.
00318 if (ACE_Thread::getspecific (log_msg_tss_key_,
00319 ACE_reinterpret_cast (void **,
00320 &tss_log_msg)) == -1)
00321 return 0; // This should not happen!
00322
00323 // Check to see if this is the first time in for this thread.
00324 if (tss_log_msg == 0)
00325 {
00326 // Allocate memory off the heap and store it in a pointer in
00327 // thread-specific storage (on the stack...). Stop heap
00328 // checking, the memory will always be freed by the thread
00329 // rundown because of the TSS callback set up when the key was
00330 // created. This prevents from getting these blocks reported as
00331 // memory leaks.
00332 {
00333 ACE_NO_HEAP_CHECK;
00334
00335 ACE_NEW_RETURN (tss_log_msg,
00336 ACE_Log_Msg,
00337 0);
00338 // Store the dynamically allocated pointer in thread-specific
00339 // storage. It gets deleted via the ACE_TSS_cleanup function
00340 // when the thread terminates.
00341
00342 if (ACE_Thread::setspecific (log_msg_tss_key_,
00343 ACE_reinterpret_cast (void *,
00344 tss_log_msg)) != 0)
00345 return 0; // Major problems, this should *never* happen!
00346 }
00347 }
00348
00349 return tss_log_msg;
00350 # else
00351 # error "Platform must support thread-specific storage if threads are used."
00352 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */
00353 #else /* ! ACE_MT_SAFE */
00354 // We don't have threads, we cannot call
00355 // ACE_Log_Msg_Manager::get_lock () to initialize the logger
00356 // callback, so instead we do it here.
00357 if (ACE_Log_Msg_Manager::init_backend () == -1)
00358 return 0;
00359
00360 // Singleton implementation.
00361 static ACE_Cleanup_Adapter<ACE_Log_Msg> *log_msg = 0;
00362 if (log_msg == 0)
00363 {
00364 ACE_NEW_RETURN (log_msg, ACE_Cleanup_Adapter<ACE_Log_Msg>, 0);
00365 // Register the instance for destruction at program termination.
00366 ACE_Object_Manager::at_exit (log_msg);
00367 }
00368
00369 return &log_msg->object ();
00370 #endif /* ! ACE_MT_SAFE */
00371 }
|
|
|
Returns last error.
Definition at line 376 of file Log_Msg.cpp. References ACE_OS::last_error.
00377 {
00378 return ACE_OS::last_error ();
00379 }
|
|
|
Get the line number where an error occurred.
Definition at line 2212 of file Log_Msg.cpp. References linenum_. Referenced by set.
02213 {
02214 return this->linenum_;
02215 }
|
|
|
Set the line number where an error occurred.
Definition at line 2218 of file Log_Msg.cpp. References linenum_.
02219 {
02220 this->linenum_ = l;
02221 }
|
|
|
Set the name of the local host.
Definition at line 2403 of file Log_Msg.cpp. References ACE_ALLOCATOR, ACE_NO_HEAP_CHECK, ACE_TCHAR, ACE_OS_Memory::free, local_host_, and ACE_OS_String::strdup.
02404 {
02405 if (s)
02406 {
02407 ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
02408 {
02409 ACE_NO_HEAP_CHECK;
02410
02411 ACE_ALLOCATOR (ACE_Log_Msg::local_host_, ACE_OS::strdup (s));
02412 }
02413 }
02414 }
|
|
|
Get the name of the local host.
Definition at line 2417 of file Log_Msg.cpp. References local_host_.
02418 {
02419 return ACE_Log_Msg::local_host_;
02420 }
|
|
||||||||||||
|
Log a custom built log record to the currently enabled logging sinks.
Definition at line 1965 of file Log_Msg.cpp. References ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_GUARD_RETURN, ACE_MT, CUSTOM, ACE_Log_Msg_Manager::custom_backend_, flags_, ACE_Log_Msg_Manager::init_backend, local_host_, ACE_Log_Msg_Backend::log, ACE_Log_Msg_Callback::log, ACE_Log_Msg_Manager::log_backend_, LOGGER, msg_callback, MSG_CALLBACK, msg_ostream, OSTREAM, ACE_Log_Record::print, SILENT, ssize_t, start_tracing, STDERR, stop_tracing, and tracing_enabled.
01967 {
01968 ssize_t result = 0;
01969
01970 // Format the message and print it to stderr and/or ship it off to
01971 // the log_client daemon, and/or print it to the ostream. Of
01972 // course, only print the message if "SILENT" mode is disabled.
01973 if (ACE_BIT_DISABLED (ACE_Log_Msg::flags_,
01974 ACE_Log_Msg::SILENT))
01975 {
01976 int tracing = this->tracing_enabled ();
01977 this->stop_tracing ();
01978
01979 #if !defined (ACE_WIN32)
01980 // Make this block signal-safe.
01981 ACE_Log_Msg_Sig_Guard sb;
01982 #endif /* !ACE_WIN32 && !ACE_PSOS */
01983
01984 // Do the callback, if needed, before acquiring the lock
01985 // to avoid holding the lock during the callback so we don't
01986 // have deadlock if the callback uses the logger.
01987 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01988 ACE_Log_Msg::MSG_CALLBACK)
01989 && this->msg_callback () != 0)
01990 this->msg_callback ()->log (log_record);
01991
01992 // Make sure that the lock is held during all this.
01993 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
01994 *ACE_Log_Msg_Manager::get_lock (),
01995 -1));
01996
01997 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01998 ACE_Log_Msg::STDERR)
01999 && !suppress_stderr) // This is taken care of by our caller.
02000 log_record.print (ACE_Log_Msg::local_host_,
02001 ACE_Log_Msg::flags_,
02002 stderr);
02003
02004 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) ||
02005 ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER))
02006 {
02007 // Be sure that there is a message_queue_, with multiple threads.
02008 ACE_MT (ACE_Log_Msg_Manager::init_backend ());
02009 }
02010
02011
02012 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
02013 ACE_Log_Msg::LOGGER))
02014 {
02015 result =
02016 ACE_Log_Msg_Manager::log_backend_->log (log_record);
02017 }
02018
02019 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM) &&
02020 ACE_Log_Msg_Manager::custom_backend_ != 0)
02021 {
02022 result =
02023 ACE_Log_Msg_Manager::custom_backend_->log (log_record);
02024 }
02025
02026
02027 // This must come last, after the other two print operations
02028 // (see the <ACE_Log_Record::print> method for details).
02029 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
02030 ACE_Log_Msg::OSTREAM)
02031 && this->msg_ostream () != 0)
02032 log_record.print (ACE_Log_Msg::local_host_,
02033 ACE_Log_Msg::flags_,
02034 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
02035 ACE_static_cast (FILE *,
02036 this->msg_ostream ())
02037 #else /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02038 *this->msg_ostream ()
02039 #endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
02040 );
02041
02042 if (tracing)
02043 this->start_tracing ();
02044 }
02045
02046 return result;
02047 }
|
|
||||||||||||||||
|
An alternative logging mechanism that makes it possible to integrate variable argument lists from other logging mechanisms into the ACE mechanism. Definition at line 910 of file Log_Msg.cpp. References ACE_OS::abort, ACE_BIT_ENABLED, ACE_hthread_t, ACE_LIB_TEXT, ACE_Log_Priority, ACE_NEW_RETURN, 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, ACE_OS::gettimeofday, inc, local_host_, log, log_priority_enabled, ACE::map_errno, ACE_Log_Record::MAXLOGMSGLEN, ACE_OS_String::memset, 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_String::strcpy, ACE_OS_String::strerror, ACE_OS_String::strlen, ACE_OS_String::strsncpy, ACE::timestamp, trace_depth_, VERBOSE, ACE_OS::WChar, and ACE_OS::wslen.
00913 {
00914 ACE_TRACE ("ACE_Log_Msg::log");
00915 // External decls.
00916
00917 #if ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) \
00918 && !defined(__MINGW32__)
00919 #if defined (__FreeBSD__) || defined(__QNX__) || defined(__APPLE__)
00920 extern const int sys_nerr;
00921 #elif defined (__CYGWIN32__)
00922 # define sys_nerr _sys_nerr
00923 #else
00924 extern int sys_nerr;
00925 #endif /* !__FreeBSD__ && !__QNX__ && !__APPLE__ */
00926 #endif /* ! (defined(__BORLANDC__) && __BORLANDC__ >= 0x0530) */
00927 typedef void (*PTF)(...);
00928
00929 // Check if there were any conditional values set.
00930 int conditional_values = this->conditional_values_.is_set_;
00931
00932 // Reset conditional values.
00933 this->conditional_values_.is_set_ = 0;
00934
00935 // Only print the message if <priority_mask_> hasn't been reset to
00936 // exclude this logging priority.
00937 if (this->log_priority_enabled (log_priority) == 0)
00938 return 0;
00939
00940 // If conditional values were set and the log priority is correct,
00941 // then the values are actually set.
00942 if (conditional_values)
00943 this->set (this->conditional_values_.file_,
00944 this->conditional_values_.line_,
00945 this->conditional_values_.op_status_,
00946 this->conditional_values_.errnum_,
00947 this->restart (),
00948 this->msg_ostream (),
00949 this->msg_callback ());
00950
00951 // Logging is a benign activity, so don't inadvertently smash errno.
00952 ACE_Errno_Guard guard (errno);
00953
00954 ACE_Log_Record log_record (log_priority,
00955 ACE_OS::gettimeofday (),
00956 this->getpid ());
00957 // bp is pointer to where to put next part of logged message.
00958 // bspace is the number of characters remaining in msg_.
00959 ACE_TCHAR *bp = ACE_const_cast (ACE_TCHAR *, this->msg ());
00960 size_t bspace = ACE_Log_Record::MAXLOGMSGLEN; // Leave room for Nul term.
00961 if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN)
00962 bspace -= ACE_static_cast (size_t, this->msg_off_);
00963
00964 // If this platform has snprintf() capability to prevent overrunning the
00965 // output buffer, use it. To avoid adding a maintenance-hassle compile-
00966 // time couple between here and OS.cpp, don't try to figure this out at
00967 // compile time. Instead, do a quick check now; if we get a -1 return,
00968 // the platform doesn't support the length-limiting capability.
00969 ACE_TCHAR test[2];
00970 int can_check = ACE_OS::snprintf (test, 1, ACE_LIB_TEXT ("x")) != -1;
00971
00972 int abort_prog = 0;
00973 int exit_value = 0;
00974
00975 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE))
00976 {
00977 // Prepend the program name onto this message
00978
00979 if (ACE_Log_Msg::program_name_ != 0)
00980 {
00981 for (const ACE_TCHAR *s = ACE_Log_Msg::program_name_;
00982 bspace > 1 && (*bp = *s) != '\0';
00983 s++, bspace--)
00984 bp++;
00985
00986 *bp++ = '|';
00987 bspace--;
00988 }
00989 }
00990
00991 while (*format_str != '\0' && bspace > 0)
00992 {
00993 // Copy input to output until we encounter a %, however a
00994 // % followed by another % is not a format specification.
00995
00996 if (*format_str != '%')
00997 {
00998 *bp++ = *format_str++;
00999 bspace--;
01000 }
01001 else if (format_str[1] == '%') // An "escaped" '%' (just print one '%').
01002 {
01003 *bp++ = *format_str++; // Store first %
01004 format_str++; // but skip second %
01005 bspace--;
01006 }
01007 else
01008 {
01009 // This is most likely a format specification that ends with
01010 // one of the valid options described previously. To enable full
01011 // use of all sprintf capabilities, save the format specifier
01012 // from the '%' up to the format letter in a new char array.
01013 // This allows the full sprintf capability for padding, field
01014 // widths, alignment, etc. Any width/precision requiring a
01015 // caller-supplied argument is extracted and placed as text
01016 // into the format array. Lastly, we convert the caller-supplied
01017 // format specifier from the ACE_Log_Msg-supported list to the
01018 // equivalent sprintf specifier, and run the new format spec
01019 // through sprintf, adding it to the bp string.
01020
01021 const ACE_TCHAR *abort_str = ACE_LIB_TEXT ("Aborting...");
01022 const ACE_TCHAR *start_format = format_str;
01023 ACE_TCHAR format[128]; // Converted format string
01024 ACE_TCHAR *fp; // Current format pointer
01025 int wp = 0; // Width/precision extracted from args
01026 int done = 0;
01027 int skip_nul_locate = 0;
01028 int this_len = 0; // How many chars s[n]printf wrote
01029
01030 fp = format;
01031 *fp++ = *format_str++; // Copy in the %
01032
01033 // Work through the format string to copy in the format
01034 // from the caller. While it's going across, extract ints
01035 // for '*' width/precision values from the argument list.
01036 // When the real format specifier is located, change it to
01037 // one recognized by sprintf, if needed, and do the sprintf
01038 // call.
01039
01040 while (!done)
01041 {
01042 done = 1; // Unless a conversion spec changes it
01043
01044 switch (*format_str)
01045 {
01046 // The initial set of cases are the conversion
01047 // specifiers. Copy them in to the format array.
01048 // Note we don't use 'l', a normal conversion spec,
01049 // as a conversion because it is a ACE_Log_Msg format
01050 // specifier.
01051 case '-':
01052 case '+':
01053 case '0':
01054 case ' ':
01055 case '#':
01056 case '1':
01057 case '2':
01058 case '3':
01059 case '4':
01060 case '5':
01061 case '6':
01062 case '7':
01063 case '8':
01064 case '9':
01065 case '.':
01066 case 'L':
01067 case 'h':
01068 *fp++ = *format_str;
01069 done = 0;
01070 break;
01071
01072 case '*':
01073 wp = va_arg (argp, int);
01074 ACE_OS::sprintf (fp, ACE_LIB_TEXT ("%d"), wp);
01075 fp += ACE_OS::strlen (fp);
01076 done = 0;
01077 break;
01078
01079 case 'A': // ACE_timer_t
01080 {
01081 #if defined (ACE_LACKS_FLOATING_POINT)
01082 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ld"));
01083 ACE_UINT32 value = va_arg (argp, ACE_UINT32);
01084 #else
01085 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("f"));
01086 double value = va_arg (argp, double);
01087 #endif /* ACE_LACKS_FLOATING_POINT */
01088 if (can_check)
01089 this_len = ACE_OS::snprintf (bp, bspace, format, value);
01090 else
01091 this_len = ACE_OS::sprintf (bp, format, value);
01092 ACE_UPDATE_COUNT (bspace, this_len);
01093 }
01094 break;
01095
01096 case 'a': // Abort program after handling all of format string.
01097 abort_prog = 1;
01098 exit_value = va_arg (argp, int);
01099 ACE_OS::strsncpy (bp, abort_str, bspace);
01100 if (bspace > ACE_OS::strlen (abort_str))
01101 bspace -= ACE_OS::strlen (abort_str);
01102 else
01103 bspace = 0;
01104 break;
01105
01106 case 'l': // Source file line number
01107 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01108 if (can_check)
01109 this_len = ACE_OS::snprintf (bp,
01110 bspace,
01111 format,
01112 this->linenum ());
01113 else
01114 this_len = ACE_OS::sprintf (bp, format, this->linenum ());
01115 ACE_UPDATE_COUNT (bspace, this_len);
01116 break;
01117
01118 case 'N': // Source file name
01119 // @@ UNICODE
01120 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01121 if (can_check)
01122 this_len = ACE_OS::snprintf (bp, bspace, format,
01123 this->file () ?
01124 ACE_TEXT_CHAR_TO_TCHAR (this->file ())
01125 : ACE_LIB_TEXT ("<unknown file>"));
01126 else
01127 this_len = ACE_OS::sprintf (bp, format,
01128 this->file () ?
01129 ACE_TEXT_CHAR_TO_TCHAR (this->file ())
01130 : ACE_LIB_TEXT ("<unknown file>"));
01131 ACE_UPDATE_COUNT (bspace, this_len);
01132 break;
01133
01134 case 'n': // Program name
01135 // @@ UNICODE
01136 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01137 if (can_check)
01138 this_len = ACE_OS::snprintf (bp, bspace, format,
01139 ACE_Log_Msg::program_name_ ?
01140 ACE_Log_Msg::program_name_ :
01141 ACE_LIB_TEXT ("<unknown>"));
01142 else
01143 this_len = ACE_OS::sprintf (bp, format,
01144 ACE_Log_Msg::program_name_ ?
01145 ACE_Log_Msg::program_name_ :
01146 ACE_LIB_TEXT ("<unknown>"));
01147 ACE_UPDATE_COUNT (bspace, this_len);
01148 break;
01149
01150 case 'P': // Process ID
01151 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01152 if (can_check)
01153 this_len = ACE_OS::snprintf
01154 (bp, bspace, format,
01155 ACE_static_cast (int, this->getpid ()));
01156 else
01157 this_len = ACE_OS::sprintf
01158 (bp, format, ACE_static_cast (int, this->getpid ()));
01159 ACE_UPDATE_COUNT (bspace, this_len);
01160 break;
01161
01162 case 'p': // <errno> string, ala perror()
01163 {
01164 errno = ACE::map_errno (this->errnum ());
01165 if (errno >= 0 && errno < sys_nerr)
01166 {
01167 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01168 if (can_check)
01169 this_len = ACE_OS::snprintf
01170 (bp, bspace, format, va_arg (argp, ACE_TCHAR *),
01171 ACE_TEXT_CHAR_TO_TCHAR (ACE_OS_String::strerror (errno)));
01172 else
01173 this_len = ACE_OS::sprintf
01174 (bp, format, va_arg (argp, ACE_TCHAR *),
01175 ACE_TEXT_CHAR_TO_TCHAR (ACE_OS_String::strerror (errno)));
01176 }
01177 else
01178 {
01179 #if defined (ACE_WIN32)
01180 ACE_TCHAR *lpMsgBuf = 0;
01181
01182 // PharLap can't do FormatMessage, so try for socket
01183 // error.
01184 # if !defined (ACE_HAS_PHARLAP)
01185 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
01186 | FORMAT_MESSAGE_MAX_WIDTH_MASK
01187 | FORMAT_MESSAGE_FROM_SYSTEM,
01188 0,
01189 errno,
01190 MAKELANGID (LANG_NEUTRAL,
01191 SUBLANG_DEFAULT),
01192 // Default language
01193 (ACE_TCHAR *) &lpMsgBuf,
01194 0,
01195 0);
01196 # endif /* ACE_HAS_PHARLAP */
01197
01198 // If we don't get a valid response from
01199 // <FormatMessage>, we'll assume this is a
01200 // WinSock error and so we'll try to convert
01201 // it into a string. If this doesn't work it
01202 // returns "unknown error" which is fine for
01203 // our purposes.
01204 if (lpMsgBuf == 0)
01205 {
01206 const ACE_TCHAR *message =
01207 ACE::sock_error (errno);
01208 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01209 if (can_check)
01210 this_len = ACE_OS::snprintf
01211 (bp, bspace, format,
01212 va_arg (argp, const ACE_TCHAR *),
01213 message);
01214 else
01215 this_len = ACE_OS::sprintf
01216 (bp, format,
01217 va_arg (argp, const ACE_TCHAR *),
01218 message);
01219 }
01220 else
01221 {
01222 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s"));
01223 if (can_check)
01224 this_len = ACE_OS::snprintf
01225 (bp, bspace, format,
01226 va_arg (argp, ACE_TCHAR *),
01227 lpMsgBuf);
01228 else
01229 this_len = ACE_OS::sprintf
01230 (bp, format,
01231 va_arg (argp, ACE_TCHAR *),
01232 lpMsgBuf);
01233 // Free the buffer.
01234 ::LocalFree (lpMsgBuf);
01235 }
01236 #elif !defined (ACE_HAS_WINCE)
01237 ACE_OS::strcpy (fp,
01238 ACE_LIB_TEXT (
01239 "s: <unknown error> = %d"));
01240 if (can_check)
01241 this_len = ACE_OS::snprintf
01242 (bp, bspace,
01243 format,
01244 va_arg (argp, ACE_TCHAR *),
01245 errno);
01246 else
01247 this_len = ACE_OS::sprintf
01248 (bp,
01249 format,
01250 va_arg (argp, ACE_TCHAR *),
01251 errno);
01252 #endif /* ACE_WIN32 */
01253 }
01254 ACE_UPDATE_COUNT (bspace, this_len);
01255 break;
01256 }
01257
01258 case 'M': // Print the name of the priority of the message.
01259 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01260 if (can_check)
01261 this_len = ACE_OS::snprintf
01262 (bp, bspace, format,
01263 ACE_Log_Record::priority_name (log_priority));
01264 else
01265 this_len = ACE_OS::sprintf
01266 (bp, format,
01267 ACE_Log_Record::priority_name (log_priority));
01268 ACE_UPDATE_COUNT (bspace, this_len);
01269 break;
01270
01271 case 'm': // Format the string assocated with the errno value.
01272 {
01273 errno = ACE::map_errno (this->errnum ());
01274 if (errno >= 0 && errno < sys_nerr)
01275 {
01276 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01277 if (can_check)
01278 this_len = ACE_OS::snprintf
01279 (bp, bspace, format,
01280 ACE_OS_String::strerror (errno));
01281 else
01282 this_len = ACE_OS::sprintf
01283 (bp, format, ACE_OS_String::strerror (errno));
01284 }
01285 else
01286 {
01287 #if defined (ACE_WIN32)
01288 ACE_TCHAR *lpMsgBuf = 0;
01289
01290 // PharLap can't do FormatMessage, so try for socket
01291 // error.
01292 # if !defined (ACE_HAS_PHARLAP)
01293 ACE_TEXT_FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
01294 | FORMAT_MESSAGE_MAX_WIDTH_MASK
01295 | FORMAT_MESSAGE_FROM_SYSTEM,
01296 0,
01297 errno,
01298 MAKELANGID (LANG_NEUTRAL,
01299 SUBLANG_DEFAULT),
01300 // Default language
01301 (ACE_TCHAR *) &lpMsgBuf,
01302 0,
01303 0);
01304 # endif /* ACE_HAS_PHARLAP */
01305
01306 // If we don't get a valid response from
01307 // <FormatMessage>, we'll assume this is a
01308 // WinSock error and so we'll try to convert
01309 // it into a string. If this doesn't work it
01310 // returns "unknown error" which is fine for
01311 // our purposes.
01312 if (lpMsgBuf == 0)
01313 {
01314 const ACE_TCHAR *message =
01315 ACE::sock_error (errno);
01316 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01317 if (can_check)
01318 this_len = ACE_OS::snprintf
01319 (bp, bspace, format, message);
01320 else
01321 this_len = ACE_OS::sprintf (bp, format, message);
01322 }
01323 else
01324 {
01325 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01326 if (can_check)
01327 this_len = ACE_OS::snprintf
01328 (bp, bspace, format, lpMsgBuf);
01329 else
01330 this_len = ACE_OS::sprintf
01331 (bp, format, lpMsgBuf);
01332 // Free the buffer.
01333 ::LocalFree (lpMsgBuf);
01334 }
01335 #elif !defined (ACE_HAS_WINCE)
01336 // Ignore the built format... if this is a problem,
01337 // this part can be changed to build another string
01338 // and pass that with the complete conversion specs.
01339 if (can_check)
01340 this_len = ACE_OS::snprintf
01341 (bp, bspace,
01342 ACE_LIB_TEXT ("<unknown error> = %d"), errno);
01343 else
01344 this_len = ACE_OS::sprintf
01345 (bp, ACE_LIB_TEXT ("<unknown error> = %d"), errno);
01346 #endif /* ACE_WIN32 */
01347 }
01348 ACE_UPDATE_COUNT (bspace, this_len);
01349 break;
01350 }
01351
01352 case 'R': // Format the return status of the operation.
01353 this->op_status (va_arg (argp, int));
01354 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("d"));
01355 if (can_check)
01356 this_len = ACE_OS::snprintf
01357 (bp, bspace, format, this->op_status ());
01358 else
01359 this_len = ACE_OS::sprintf
01360 (bp, format, this->op_status ());
01361 ACE_UPDATE_COUNT (bspace, this_len);
01362 break;
01363
01364 case '{': // Increment the trace_depth, then indent
01365 skip_nul_locate = 1;
01366 (void) this->inc ();
01367 break;
01368
01369 case '}': // indent, then decrement trace_depth
01370 skip_nul_locate = 1;
01371 (void) this->dec ();
01372 break;
01373
01374 case '$': // insert a newline, then indent the next line
01375 // according to %I
01376 *bp++ = '\n';
01377 bspace--;
01378 /* fallthrough */
01379
01380 case 'I': // Indent with nesting_depth*width spaces
01381 // Caller can do %*I to override nesting indent, and
01382 // if %*I was done, wp has the extracted width.
01383 if (0 == wp)
01384 wp = ACE_Trace::get_nesting_indent ();
01385 wp *= this->trace_depth_;
01386 if (ACE_static_cast (size_t, wp) > bspace)
01387 wp = ACE_static_cast (int, bspace);
01388 ACE_OS::memset (bp, ' ', wp);
01389 bp += wp;
01390 *bp = '\0';
01391 bspace -= ACE_static_cast (size_t, wp);
01392 skip_nul_locate = 1;
01393 break;
01394
01395 case 'r': // Run (invoke) this subroutine.
01396 {
01397 int osave = ACE_Log_Msg::msg_off_;
01398
01399 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01400 ACE_Log_Msg::SILENT) &&
01401 bspace > 1)
01402 {
01403 *bp++ = '{';
01404 bspace--;
01405 }
01406 ACE_Log_Msg::msg_off_ = bp - this->msg_;
01407
01408 (*va_arg (argp, PTF))();
01409
01410 if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_,
01411 ACE_Log_Msg::SILENT) &&
01412 bspace > (1 + ACE_OS::strlen (bp)))
01413 {
01414 bspace -= (ACE_OS::strlen (bp) + 1);
01415 bp += ACE_OS::strlen (bp);
01416 *bp++ = '}';
01417 }
01418 *bp = '\0';
01419 skip_nul_locate = 1;
01420 ACE_Log_Msg::msg_off_ = osave;
01421 break;
01422 }
01423
01424 case 'S': // format the string for with this signal number.
01425 {
01426 int sig = va_arg (argp, int);
01427 #if defined (ACE_HAS_SYS_SIGLIST)
01428 if (sig >= 0 && sig < ACE_NSIG)
01429 {
01430 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01431 if (can_check)
01432 this_len = ACE_OS::snprintf
01433 (bp, bspace, format, _sys_siglist[sig]);
01434 else
01435 this_len = ACE_OS::sprintf
01436 (bp, format, _sys_siglist[sig]);
01437 }
01438 else
01439 {
01440 if (can_check)
01441 this_len = ACE_OS::snprintf
01442 (bp, bspace,
01443 ACE_LIB_TEXT("<unknown signal> %d"), sig);
01444 else
01445 this_len = ACE_OS::sprintf
01446 (bp, ACE_LIB_TEXT ("<unknown signal> %d"), sig);
01447 }
01448 #else
01449 if (can_check)
01450 this_len = ACE_OS::snprintf
01451 (bp, bspace, ACE_LIB_TEXT ("signal %d"), sig);
01452 else
01453 this_len = ACE_OS::sprintf
01454 (bp, ACE_LIB_TEXT ("signal %d"), sig);
01455 #endif /* ACE_HAS_SYS_SIGLIST */
01456 ACE_UPDATE_COUNT (bspace, this_len);
01457 break;
01458 }
01459
01460 case 'D': // Format the timestamp in month/day/year
01461 // hour:minute:sec:usec format.
01462 {
01463 ACE_TCHAR day_and_time[35];
01464 ACE::timestamp (day_and_time,
01465 sizeof day_and_time);
01466 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01467 if (can_check)
01468 this_len = ACE_OS::snprintf
01469 (bp, bspace, format, day_and_time);
01470 else
01471 this_len = ACE_OS::sprintf (bp, format, day_and_time);
01472 ACE_UPDATE_COUNT (bspace, this_len);
01473 break;
01474 }
01475
01476 case 'T': // Format the timestamp in
01477 // hour:minute:sec:usec format.
01478 {
01479 ACE_TCHAR day_and_time[35];
01480 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01481 if (can_check)
01482 this_len = ACE_OS::snprintf
01483 (bp, bspace, format,
01484 ACE::timestamp (day_and_time, sizeof day_and_time));
01485 else
01486 this_len = ACE_OS::sprintf
01487 (bp, format, ACE::timestamp (day_and_time,
01488 sizeof day_and_time));
01489 ACE_UPDATE_COUNT (bspace, this_len);
01490 break;
01491 }
01492
01493 case 't': // Format thread id.
01494 #if defined (ACE_WIN32)
01495 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01496 if (can_check)
01497 this_len = ACE_OS::snprintf
01498 (bp, bspace, format,
01499 ACE_static_cast(unsigned, ACE_Thread::self ()));
01500 else
01501 this_len = ACE_OS::sprintf
01502 (bp, format, ACE_static_cast(unsigned,
01503 ACE_Thread::self ()));
01504 #elif defined (ACE_AIX_VERS) && (ACE_AIX_VERS <= 402)
01505 // AIX's pthread_t (ACE_hthread_t) is a pointer, and it's
01506 // a little ugly to send that through a %u format. So,
01507 // get the kernel thread ID (tid_t) via thread_self() and
01508 // display that instead.
01509 // This isn't conditionalized on ACE_HAS_THREAD_SELF because
01510 // 1. AIX 4.2 doesn't have that def anymore (it messes up
01511 // other things)
01512 // 2. OSF/1 V3.2 has that def, and I'm not sure what affect
01513 // this would have on that.
01514 // -Steve Huston, 19-Aug-97
01515 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01516 if (can_check)
01517 this_len = ACE_OS::snprintf
01518 (bp, bspace, format, thread_self());
01519 else
01520 this_len = ACE_OS::sprintf (bp, format, thread_self());
01521 #elif defined (DIGITAL_UNIX)
01522 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01523 {
01524 int id =
01525 # if defined (ACE_HAS_THREADS)
01526 pthread_getselfseq_np ();
01527 # else
01528 ACE_Thread::self ();
01529 # endif /* ACE_HAS_THREADS */
01530
01531 if (can_check)
01532 this_len = ACE_OS::snprintf (bp, bspace, format, id);
01533 else
01534 this_len = ACE_OS::sprintf (bp, format, id);
01535 }
01536 #else
01537 ACE_hthread_t t_id;
01538 ACE_Thread::self (t_id);
01539
01540 # if defined (ACE_HAS_PTHREADS_DRAFT4) && defined (HPUX_10)
01541 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01542 // HP-UX 10.x DCE's thread ID is a pointer. Grab the
01543 // more meaningful, readable, thread ID. This will match
01544 // the one seen in the debugger as well.
01545 if (can_check)
01546 this_len = ACE_OS::snprintf (bp, bspace, format,
01547 pthread_getunique_np (&t_id));
01548 else
01549 this_len = ACE_OS::sprintf (bp, format,
01550 pthread_getunique_np (&t_id));
01551 # elif defined (ACE_MVS)
01552 // MVS's pthread_t is a struct... yuck. So use the ACE 5.0
01553 // code for it.
01554 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01555 if (can_check)
01556 this_len = ACE_OS::snprintf (bp, bspace, format, t_id);
01557 else
01558 this_len = ACE_OS::sprintf (bp, format, t_id);
01559 # else
01560 // Yes, this is an ugly C-style cast, but the correct
01561 // C++ cast is different depending on whether the t_id
01562 // is an integral type or a pointer type. FreeBSD uses
01563 // a pointer type, but doesn't have a _np function to
01564 // get an integral type, like the OSes above.
01565 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lu"));
01566 if (can_check)
01567 this_len = ACE_OS::snprintf
01568 (bp, bspace, format, (unsigned long)t_id);
01569 else
01570 this_len = ACE_OS::sprintf
01571 (bp, format, (unsigned long)t_id);
01572 # endif /* ACE_HAS_PTHREADS_DRAFT4 && HPUX_10 */
01573
01574 #endif /* ACE_WIN32 */
01575 ACE_UPDATE_COUNT (bspace, this_len);
01576 break;
01577
01578 case 's': // String
01579 #if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01580 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01581 if (can_check)
01582 this_len = ACE_OS::snprintf
01583 (bp, bspace, format, va_arg (argp, wchar_t *));
01584 else
01585 this_len = ACE_OS::sprintf
01586 (bp, format, va_arg (argp, wchar_t *));
01587 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01588 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01589 if (can_check)
01590 this_len = ACE_OS::snprintf
01591 (bp, bspace, format, va_arg (argp, ACE_TCHAR *));
01592 else
01593 this_len = ACE_OS::sprintf
01594 (bp, format, va_arg (argp, ACE_TCHAR *));
01595 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01596 ACE_UPDATE_COUNT (bspace, this_len);
01597 break;
01598
01599 case 'C': // Char string, Unicode for Win32/WCHAR
01600 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01601 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01602 #else /* ACE_WIN32 && ACE_USES_WCHAR */
01603 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01604 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01605 if (can_check)
01606 this_len = ACE_OS::snprintf
01607 (bp, bspace, format, va_arg (argp, ACE_TCHAR *));
01608 else
01609 this_len = ACE_OS::sprintf
01610 (bp, format, va_arg (argp, ACE_TCHAR *));
01611 ACE_UPDATE_COUNT (bspace, this_len);
01612 break;
01613
01614 case 'W':
01615 #if defined (ACE_WIN32)
01616 # if defined (ACE_USES_WCHAR)
01617 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01618 # else /* ACE_USES_WCHAR */
01619 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01620 # endif /* ACE_USES_WCHAR */
01621 if (can_check)
01622 this_len = ACE_OS::snprintf
01623 (bp, bspace, format, va_arg (argp, ACE_TCHAR *));
01624 else
01625 this_len = ACE_OS::sprintf
01626 (bp, format, va_arg (argp, ACE_TCHAR *));
01627 #elif defined (ACE_HAS_WCHAR)
01628 # if defined (HPUX)
01629 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01630 # else
01631 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01632 # endif /* HPUX */
01633 if (can_check)
01634 this_len = ACE_OS::snprintf
01635 (bp, bspace, format, va_arg (argp, wchar_t *));
01636 else
01637 this_len = ACE_OS::sprintf
01638 (bp, format, va_arg (argp, wchar_t *));
01639 #endif /* ACE_WIN32 / ACE_HAS_WCHAR */
01640 ACE_UPDATE_COUNT (bspace, this_len);
01641 break;
01642
01643 case 'w': // Wide character
01644 #if defined (ACE_WIN32)
01645 # if defined (ACE_USES_WCHAR)
01646 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01647 # else /* ACE_USES_WCHAR */
01648 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01649 # endif /* ACE_USES_WCHAR */
01650 if (can_check)
01651 this_len = ACE_OS::snprintf
01652 (bp, bspace, format, va_arg (argp, int));
01653 else
01654 this_len = ACE_OS::sprintf
01655 (bp, format, va_arg (argp, int));
01656 #elif defined (ACE_USES_WCHAR)
01657 # if defined (HPUX)
01658 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01659 # else
01660 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lc"));
01661 # endif /* HPUX */
01662 if (can_check)
01663 this_len = ACE_OS::snprintf
01664 (bp, bspace, format, va_arg (argp, wint_t));
01665 else
01666 this_len = ACE_OS::sprintf
01667 (bp, format, va_arg (argp, wint_t));
01668 #else /* ACE_WIN32 */
01669 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01670 if (can_check)
01671 this_len = ACE_OS::snprintf
01672 (bp, bspace, format, va_arg (argp, int));
01673 else
01674 this_len = ACE_OS::sprintf
01675 (bp, format, va_arg (argp, int));
01676 #endif /* ACE_WIN32 */
01677 ACE_UPDATE_COUNT (bspace, this_len);
01678 break;
01679
01680 case 'z': // ACE_OS::WChar character
01681 {
01682 // On some platforms sizeof (wchar_t) can be 2
01683 // on the others 4 ...
01684 wchar_t wtchar =
01685 ACE_static_cast(wchar_t,
01686 va_arg (argp, int));
01687 #if defined (ACE_WIN32)
01688 # if defined (ACE_USES_WCHAR)
01689 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01690 # else /* ACE_USES_WCHAR */
01691 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01692 # endif /* ACE_USES_WCHAR */
01693 #elif defined (ACE_USES_WCHAR)
01694 # if defined (HPUX)
01695 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01696 # else
01697 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("lc"));
01698 # endif /* HPUX */
01699 #else /* ACE_WIN32 */
01700 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("u"));
01701 #endif /* ACE_WIN32 */
01702 if (can_check)
01703 this_len = ACE_OS::snprintf (bp, bspace, format, wtchar);
01704 else
01705 this_len = ACE_OS::sprintf (bp, format, wtchar);
01706 ACE_UPDATE_COUNT (bspace, this_len);
01707 break;
01708 }
01709
01710 case 'Z': // ACE_OS::WChar character string
01711 {
01712 ACE_OS::WChar *wchar_str = va_arg (argp, ACE_OS::WChar*);
01713 if (wchar_str == 0)
01714 break;
01715
01716 wchar_t *wchar_t_str = 0;
01717 if (sizeof (ACE_OS::WChar) != sizeof (wchar_t))
01718 {
01719 size_t len = ACE_OS::wslen (wchar_str) + 1;
01720 //@@ Bad, but there is no such ugly thing as
01721 // ACE_NEW_BREAK and ACE_NEW has a return
01722 // statement inside.
01723 ACE_NEW_RETURN(wchar_t_str, wchar_t[len], 0);
01724 if (wchar_t_str == 0)
01725 break;
01726
01727 for (size_t i = 0; i < len; i++)
01728 {
01729 wchar_t_str[i] = wchar_str[i];
01730 }
01731 }
01732
01733 if (wchar_t_str == 0)
01734 {
01735 wchar_t_str = ACE_reinterpret_cast(wchar_t*,
01736 wchar_str);
01737 }
01738 #if defined (ACE_WIN32)
01739 # if defined (ACE_USES_WCHAR)
01740 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s"));
01741 # else /* ACE_USES_WCHAR */
01742 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01743 # endif /* ACE_USES_WCHAR */
01744 #elif defined (ACE_HAS_WCHAR)
01745 # if defined (HPUX)
01746 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("S"));
01747 # else
01748 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls"));
01749 # endif /* HPUX */
01750 #endif /* ACE_WIN32 / ACE_HAS_WCHAR */
01751 if (can_check)
01752 this_len = ACE_OS::snprintf
01753 (bp, bspace, format, wchar_t_str);
01754 else
01755 this_len = ACE_OS::sprintf (bp, format, wchar_t_str);
01756 if(sizeof(ACE_OS::WChar) != sizeof(wchar_t))
01757 {
01758 delete wchar_t_str;
01759 }
01760 ACE_UPDATE_COUNT (bspace, this_len);
01761 break;
01762 }
01763
01764 case 'c':
01765 #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
01766 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("C"));
01767 #else
01768 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("c"));
01769 #endif /* ACE_WIN32 && ACE_USES_WCHAR */
01770 if (can_check)
01771 this_len = ACE_OS::snprintf
01772 (bp, bspace, format, va_arg (argp, int));
01773 else
01774 this_len = ACE_OS::sprintf
01775 (bp, format, va_arg (argp, int));
01776 ACE_UPDATE_COUNT (bspace, this_len);
01777 break;
01778
01779 case 'd': case 'i': case 'o':
01780 case 'u': case 'x': case 'X':
01781 fp[0] = *format_str;
01782 fp[1] = '\0';
01783 if (can_check)
01784 this_len = ACE_OS::snprintf
01785 (bp, bspace, format, va_arg (argp, int));
01786 else
01787 this_len = ACE_OS::sprintf
01788 (bp, format, va_arg (argp, int));
01789 ACE_UPDATE_COUNT (bspace, this_len);
01790 break;
01791
01792 case 'F': case 'f': case 'e': case 'E':
01793 case 'g': case 'G':
01794 fp[0] = *format_str;
01795 fp[1] = '\0';
01796 if (can_check)
01797 this_len = ACE_OS::snprintf
01798 (bp, bspace, format, va_arg (argp, double));
01799 else
01800 this_len = ACE_OS::sprintf
01801 (bp, format, va_arg (argp, double));
01802 ACE_UPDATE_COUNT (bspace, this_len);
01803 break;
01804
01805 case 'Q':
01806 #if defined (ACE_LACKS_LONGLONG_T)
01807 {
01808 // This relies on the ACE_U_LongLong storage layout.
01809 ACE_UINT32 hi = va_arg (argp, ACE_UINT32);
01810 ACE_UINT32 lo = va_arg (argp, ACE_UINT32);
01811 if (hi > 0)
01812 this_len = ACE_OS::sprintf (bp,
01813 "0x%lx%0*lx",
01814 hi,
01815 2 * sizeof lo,
01816 lo);
01817 else
01818 this_len = ACE_OS::sprintf (bp, "0x%lx", lo);
01819 }
01820 #else /* ! ACE_LACKS_LONGLONG_T */
01821 {
01822 const ACE_TCHAR *fmt = ACE_UINT64_FORMAT_SPECIFIER;
01823 ACE_OS::strcpy (fp, &fmt[1]); // Skip leading %
01824 if (can_check)
01825 this_len = ACE_OS::snprintf (bp, bspace,
01826 format,
01827 va_arg (argp, ACE_UINT64));
01828 else
01829 this_len = ACE_OS::sprintf (bp,
01830 format,
01831 va_arg (argp, ACE_UINT64));
01832 }
01833 #endif /* ! ACE_LACKS_LONGLONG_T */
01834 ACE_UPDATE_COUNT (bspace, this_len);
01835 break;
01836
01837 case '@':
01838 ACE_OS::strcpy (fp, ACE_LIB_TEXT ("p"));
01839 if (can_check)
01840 this_len = ACE_OS::snprintf
01841 (bp, bspace, format, va_arg (argp, void*));
01842 else
01843 this_len = ACE_OS::sprintf
01844 (bp, format, va_arg (argp, void*));
01845 ACE_UPDATE_COUNT (bspace, this_len);
01846 break;
01847
01848 default:
01849 // So, it's not a legit format specifier after all...
01850 // Copy from the original % to where we are now, then
01851 // continue with whatever comes next.
01852 while (start_format != format_str && bspace > 0)
01853 {
01854 *bp++ = *start_format++;
01855 bspace--;
01856 }
01857 if (bspace > 0)
01858 {
01859 *bp++ = *format_str;
01860 bspace--;
01861 }
01862 break;
01863 }
01864
01865 // Bump to the next char in the caller's format_str
01866 format_str++;
01867 }
01868
01869 if (!skip_nul_locate)
01870 while (*bp != '\0') // Locate end of bp.
01871 bp++;
01872 }
01873 }
01874
01875 *bp = '\0'; // Terminate bp, but don't auto-increment this!
01876
01877 // Check that memory was not corrupted.
01878 if (bp >= this->msg_ + sizeof this->msg_)
01879 {
01880 abort_prog = 1;
01881 ACE_OS::fprintf (stderr,
01882 "The following logged message is too long!\n");
01883 }
01884
01885 // Copy the message from thread-specific storage into the transfer
01886 // buffer (this can be optimized away by changing other code...).
01887 log_record.msg_data (this->msg ());
01888
01889 // Write the <log_record> to the appropriate location.
01890 ssize_t result = this->log (log_record,
01891 abort_prog);
01892
01893 if (abort_prog)
01894 {
01895 // Since we are now calling abort instead of exit, this value is
01896 // not used.
01897 ACE_UNUSED_ARG (exit_value);
01898
01899 // *Always* print a message to stderr if we're aborting. We
01900 // don't use verbose, however, to avoid recursive aborts if
01901 // something is hosed.
01902 log_record.print (ACE_Log_Msg::local_host_, 0, stderr);
01903 ACE_OS::abort ();
01904 }
01905
01906 return result;
01907 }
|
|
||||||||||||||||
|
Since this is the ANTI_TCHAR version, we need to convert the format string over. Definition at line 890 of file Log_Msg.cpp. References ACE_ANTI_TCHAR, ACE_Log_Priority, ACE_TEXT_ANTI_TO_TCHAR, ACE_TRACE, and log.
00892 {
00893 ACE_TRACE ("ACE_Log_Msg::log");
00894
00895 // Start of variable args section.
00896 va_list argp;
00897
00898 va_start (argp, format_str);
00899
00900 int result = this->log (ACE_TEXT_ANTI_TO_TCHAR (format_str),
00901 log_priority,
00902 argp);
00903 va_end (argp);
00904
00905 return result;
00906 }
|
|
||||||||||||||||
|
Format a message to the thread-safe ACE logging mechanism. Valid options (prefixed by '%', as in printf format strings) include:
Definition at line 866 of file Log_Msg.cpp. References ACE_Log_Priority, ACE_TCHAR, and ACE_TRACE. Referenced by 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 2052 of file Log_Msg.cpp. References ACE_LIB_TEXT, ACE_Log_Priority, ACE_NEW_RETURN, ACE_TCHAR, ACE::format_hexdump, log, ACE_Log_Record::MAXLOGMSGLEN, ACE_OS::sprintf, ACE_OS_String::strlen, and ACE_Log_Record::VERBOSE_LEN.
02056 {
02057 ACE_TCHAR buf[ACE_Log_Record::MAXLOGMSGLEN -
02058 ACE_Log_Record::VERBOSE_LEN - 58];
02059 // 58 for the HEXDUMP header;
02060
02061 ACE_TCHAR *msg_buf;
02062 size_t text_sz = text ? ACE_OS_String::strlen(text) : 0;
02063 ACE_NEW_RETURN (msg_buf,
02064 ACE_TCHAR[text_sz + 58],
02065 -1);
02066
02067 buf[0] = 0; // in case size = 0
02068
02069 size_t len = ACE::format_hexdump
02070 (buffer, size, buf, sizeof (buf) / sizeof (ACE_TCHAR) - text_sz);
02071
02072 int sz = 0;
02073
02074 if (text)
02075 sz = ACE_OS::sprintf (msg_buf,
02076 ACE_LIB_TEXT ("%s - "),
02077 text);
02078
02079 sz += ACE_OS::sprintf (msg_buf + sz,
02080 ACE_LIB_TEXT ("HEXDUMP %ld bytes"),
02081 (long int)size);
02082
02083 if (len < size)
02084 ACE_OS::sprintf (msg_buf + sz,
02085 ACE_LIB_TEXT (" (showing first %ld bytes)"),
02086 (long int)len);
02087
02088 // Now print out the formatted buffer.
02089 this->log (log_priority,
02090 ACE_LIB_TEXT ("%s\n%s"),
02091 msg_buf,
02092 buf);
02093
02094 delete [] msg_buf;
02095 return 0;
02096 }
|
|
||||||||||||||||
|
Return true if the requested priority is enabled.
Definition at line 2432 of file Log_Msg.cpp. References ACE_Log_Priority, and log_priority_enabled.
02435 {
02436 return this->log_priority_enabled (log_priority);
02437 }
|
|
|
Return true if the requested priority is enabled.
Definition at line 591 of file Log_Msg.cpp. References ACE_BIT_ENABLED, ACE_Log_Priority, and process_priority_mask_. Referenced by log, and log_priority_enabled.
00592 {
00593 return ACE_BIT_ENABLED (this->priority_mask_ |
00594 ACE_Log_Msg::process_priority_mask_,
00595 log_priority);
00596 }
|
|
|
Get the message that describes what type of error occurred.
Definition at line 2335 of file Log_Msg.cpp. References msg_, and msg_off_.
02336 {
02337 return this->msg_ + ACE_Log_Msg::msg_off_;
02338 }
|
|
|
Set the message that describes what type of error occurred.
Definition at line 2341 of file Log_Msg.cpp. References ACE_TCHAR, and ACE_OS_String::strsncpy.
02342 {
02343 ACE_OS::strsncpy (this->msg_, m,
02344 (sizeof this->msg_ / sizeof (ACE_TCHAR)));
02345 }
|
|
|
Definition at line 2374 of file Log_Msg.cpp. References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, and ACE_Log_Msg_Manager::custom_backend_.
02375 {
02376 ACE_TRACE ("ACE_Log_Msg::msg_backend");
02377 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
02378 *ACE_Log_Msg_Manager::get_lock (), 0));
02379
02380 return ACE_Log_Msg_Manager::custom_backend_;
02381 }
|
|
|
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. Note: Be aware that because of the current architecture there is no guarantee that open (), reset () and close () will be called on a backend object. Definition at line 2362 of file Log_Msg.cpp. References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, and ACE_Log_Msg_Manager::custom_backend_.
02363 {
02364 ACE_TRACE ("ACE_Log_Msg::msg_backend");
02365 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
02366 *ACE_Log_Msg_Manager::get_lock (), 0));
02367
02368 ACE_Log_Msg_Backend *tmp = ACE_Log_Msg_Manager::custom_backend_;
02369 ACE_Log_Msg_Manager::custom_backend_ = b;
02370 return tmp;
02371 }
|
|
|
Definition at line 2348 of file Log_Msg.cpp. References msg_callback_.
02349 {
02350 return this->msg_callback_;
02351 }
|
|
|
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 2354 of file Log_Msg.cpp. References msg_callback_.
02355 {
02356 ACE_Log_Msg_Callback *old = this->msg_callback_;
02357 this->msg_callback_ = c;
02358 return old;
02359 }
|
|
|
Get the ostream that is used to print error messages.
Definition at line 2384 of file Log_Msg.cpp. References ostream_. Referenced by log, open, and set.
02385 {
02386 return this->ostream_;
02387 }
|
|
||||||||||||
|
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 2390 of file Log_Msg.cpp. References delete_ostream_, and ostream_.
02391 {
02392 this->delete_ostream_ = delete_ostream;
02393 this->ostream_ = m;
02394 }
|
|
|
Update the ostream without overwriting the delete_ostream_ flag.
Definition at line 2397 of file Log_Msg.cpp. References ostream_. Referenced by ACE_Logging_Strategy::handle_timeout, inherit_hook, ACE_Logging_Strategy::init, and init_hook.
02398 {
02399 this->ostream_ = m;
02400 }
|
|
|
Get the result of the operation status (by convention, -1 means error).
Definition at line 2182 of file Log_Msg.cpp. References status_.
02183 {
02184 return this->status_;
02185 }
|
|
|
Set the result of the operation status (by convention, -1 means error).
Definition at line 2176 of file Log_Msg.cpp. References status_.
02177 {
02178 this->status_ = status;
02179 }
|
|
||||||||||||||||
|
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 710 of file Log_Msg.cpp. References ACE_ALLOCATOR_RETURN, ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_DEFAULT_LOG_STREAM, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_NO_HEAP_CHECK, ACE_SET_BITS, ACE_TCHAR, ACE_TRACE, CUSTOM, ACE_Log_Msg_Manager::custom_backend_, flags, flags_, ACE_OS_Memory::free, ACE_Log_Msg_Manager::init_backend, ACE_Log_Msg_Manager::log_backend_, LOGGER, MSG_CALLBACK, msg_ostream, ACE_Log_Msg_Backend::open, OSTREAM, program_name_, ACE_Log_Msg_Backend::reset, SILENT, STDERR, ACE_OS_String::strdup, SYSLOG, VERBOSE, and VERBOSE_LITE. Referenced by inherit_hook, ACE_Logging_Strategy::init, and ACE_Service_Config::open_i.
00713 {
00714 ACE_TRACE ("ACE_Log_Msg::open");
00715 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00716 *ACE_Log_Msg_Manager::get_lock (), -1));
00717
00718 if (prog_name)
00719 {
00720 ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
00721
00722 // Stop heap checking, block will be freed by the destructor.
00723 {
00724 ACE_NO_HEAP_CHECK;
00725
00726 ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_,
00727 ACE_OS::strdup (prog_name),
00728 -1);
00729 }
00730 }
00731 else if (ACE_Log_Msg::program_name_ == 0)
00732 {
00733 // Stop heap checking, block will be freed by the destructor.
00734 ACE_NO_HEAP_CHECK;
00735 ACE_ALLOCATOR_RETURN (ACE_Log_Msg::program_name_,
00736 ACE_OS::strdup (ACE_LIB_TEXT ("<unknown>")),
00737 -1);
00738 }
00739
00740 int status = 0;
00741
00742 // Be sure that there is a message_queue_, with multiple threads.
00743 ACE_MT (ACE_Log_Msg_Manager::init_backend (&flags));
00744
00745 // Always close the current handle before doing anything else.
00746 if (ACE_Log_Msg_Manager::log_backend_ != 0)
00747 ACE_Log_Msg_Manager::log_backend_->reset ();
00748
00749 if (ACE_Log_Msg_Manager::custom_backend_ != 0)
00750 ACE_Log_Msg_Manager::custom_backend_->reset ();
00751
00752 // Note that if we fail to open the message queue the default action
00753 // is to use stderr (set via static initialization in the
00754 // Log_Msg.cpp file).
00755
00756 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER)
00757 || ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG))
00758 {
00759 // The SYSLOG backends (both NT and UNIX) can get along fine
00760 // without the logger_key.
00761 if (logger_key == 0 && ACE_BIT_ENABLED (flags, ACE_Log_Msg::LOGGER))
00762 status = -1;
00763 else
00764 {
00765 status =
00766 ACE_Log_Msg_Manager::log_backend_->open (logger_key);
00767 }
00768
00769 if (status == -1)
00770 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR);
00771 else
00772 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER);
00773 }
00774 else if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER))
00775 {
00776 // If we are closing down logger, redirect logging to stderr.
00777 ACE_CLR_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::LOGGER);
00778 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::STDERR);
00779 }
00780
00781 if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM))
00782 {
00783 status =
00784 ACE_Log_Msg_Manager::custom_backend_->open (logger_key);
00785
00786 if (status != -1)
00787 ACE_SET_BITS (ACE_Log_Msg::flags_, ACE_Log_Msg::CUSTOM);
00788 }
00789
00790 // Remember, ACE_Log_Msg::STDERR bit is on by default...
00791 if (status != -1
00792 && ACE_BIT_ENABLED (flags,
00793 ACE_Log_Msg::STDERR) == 0)
00794 ACE_CLR_BITS (ACE_Log_Msg::flags_,
00795 ACE_Log_Msg::STDERR);
00796
00797 // VERBOSE takes precedence over VERBOSE_LITE...
00798 if (ACE_BIT_ENABLED (flags,
00799 ACE_Log_Msg::VERBOSE_LITE))
00800 ACE_SET_BITS (ACE_Log_Msg::flags_,
00801 ACE_Log_Msg::VERBOSE_LITE);
00802 else if (ACE_BIT_ENABLED (flags,
00803 ACE_Log_Msg::VERBOSE))
00804 ACE_SET_BITS (ACE_Log_Msg::flags_,
00805 ACE_Log_Msg::VERBOSE);
00806
00807 if (ACE_BIT_ENABLED (flags,
00808 ACE_Log_Msg::OSTREAM))
00809 {
00810 ACE_SET_BITS (ACE_Log_Msg::flags_,
00811 ACE_Log_Msg::OSTREAM);
00812 // Only set this to cerr if it hasn't already been set.
00813 if (this->msg_ostream () == 0)
00814 this->msg_ostream (ACE_DEFAULT_LOG_STREAM);
00815 }
00816
00817 if (ACE_BIT_ENABLED (flags,
00818 ACE_Log_Msg::MSG_CALLBACK))
00819 ACE_SET_BITS (ACE_Log_Msg::flags_,
00820 ACE_Log_Msg::MSG_CALLBACK);
00821
00822 if (ACE_BIT_ENABLED (flags,
00823 ACE_Log_Msg::SILENT))
00824 ACE_SET_BITS (ACE_Log_Msg::flags_,
00825 ACE_Log_Msg::SILENT);
00826
00827 return status;
00828 }
|
|
|
|
|
||||||||||||
|
Set the ACE_Log_Priority mask, returns original mask.
Definition at line 567 of file Log_Msg.cpp. References priority_mask_, process_priority_mask_, and THREAD.
00568 {
00569 u_long o_mask;
00570
00571 if (mask_type == THREAD) {
00572 o_mask = this->priority_mask_;
00573 this->priority_mask_ = n_mask;
00574 }
00575 else {
00576 o_mask = ACE_Log_Msg::process_priority_mask_;
00577 ACE_Log_Msg::process_priority_mask_ = n_mask;
00578 }
00579
00580 return o_mask;
00581 }
|
|
|
Get the current ACE_Log_Priority mask.
Definition at line 584 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_Config::open_i.
00585 {
00586 return mask_type == THREAD ? this->priority_mask_
00587 : ACE_Log_Msg::process_priority_mask_;
00588 }
|
|
|
Returns the current program name used for logging.
Definition at line 404 of file Log_Msg.cpp. References program_name_.
00405 {
00406 return ACE_Log_Msg::program_name_;
00407 }
|
|
|
Release the internal lock.
Definition at line 599 of file Log_Msg.cpp. References ACE_TRACE, and ACE_Recursive_Thread_Mutex::release. Referenced by ACE_Logging_Strategy::handle_timeout.
00600 {
00601 ACE_TRACE ("ACE_Log_Msg::release");
00602
00603 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00604 return ACE_Log_Msg_Manager::get_lock ()->release ();
00605 #else /* ! ACE_MT_SAFE */
00606 return 0;
00607 #endif /* ! ACE_MT_SAFE */
00608 }
|
|
|
Get the field that indicates whether interrupted calls should be restarted.
Definition at line 2194 of file Log_Msg.cpp. References restart_. Referenced by set.
02195 {
02196 return this->restart_;
02197 }
|
|
|
Set the field that indicates whether interrupted calls should be restarted.
Definition at line 2188 of file Log_Msg.cpp. References restart_. Referenced by inherit_hook, and init_hook.
02189 {
02190 this->restart_ = r;
02191 }
|
|
||||||||||||||||||||||||||||||||
|
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 2099 of file Log_Msg.cpp. References ACE_TRACE, errnum, file, linenum, msg_callback, msg_ostream, op_status, and restart. Referenced by log.
02106 {
02107 ACE_TRACE ("ACE_Log_Msg::set");
02108 this->file (filename);
02109 this->linenum (line);
02110 this->op_status (status);
02111 this->errnum (err);
02112 this->restart (rs);
02113 this->msg_ostream (os);
02114 this->msg_callback (c);
02115 }
|
|
|
Enable the bits in the logger's options flags. Definition at line 536 of file Log_Msg.cpp. References ACE_GUARD, ACE_MT, ACE_SET_BITS, ACE_TRACE, and flags_. Referenced by ACE_Logging_Strategy::init.
00537 {
00538 ACE_TRACE ("ACE_Log_Msg::set_flags");
00539 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00540 *ACE_Log_Msg_Manager::get_lock ()));
00541
00542 ACE_SET_BITS (ACE_Log_Msg::flags_, flgs);
00543 }
|
|
|
Start tracing status on a per-thread basis...
Definition at line 2303 of file Log_Msg.cpp. References tracing_enabled_. Referenced by inherit_hook, and log.
02304 {
02305 this->tracing_enabled_ = 1;
02306 }
|
|
|
Stop tracing status on a per-thread basis...
Definition at line 2311 of file Log_Msg.cpp. References tracing_enabled_. Referenced by log.
02312 {
02313 this->tracing_enabled_ = 0;
02314 }
|
|
|
Call after doing a
Definition at line 500 of file Log_Msg.cpp. References ACE_NO_HEAP_CHECK, ACE_TCHAR, ACE_TRACE, ACE_OS_Memory::free, ACE_OS::getpid, msg_off_, pid_, program_name_, and ACE_OS_String::strdup.
00501 {
00502 ACE_TRACE ("ACE_Log_Msg::sync");
00503
00504 if (prog_name)
00505 {
00506 // Must free if already allocated!!!
00507 ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
00508
00509 // Stop heap checking, block will be freed by the destructor when
00510 // the last ACE_Log_Msg instance is deleted.
00511 // Heap checking state will be restored when the block is left.
00512 {
00513 ACE_NO_HEAP_CHECK;
00514
00515 ACE_Log_Msg::program_name_ = ACE_OS::strdup (prog_name);
00516 }
00517 }
00518
00519 ACE_Log_Msg::pid_ = ACE_OS::getpid ();
00520 ACE_Log_Msg::msg_off_ = 0;
00521 }
|
|
|
Decouple the OS layer from the ACE_Log_Msg layer.
Definition at line 486 of file Log_Msg.cpp. References ACE_LOG_MSG, and ACE_TCHAR. Referenced by ACE_Log_Msg.
00487 {
00488 ACE_LOG_MSG->sync (prg_name);
00489 }
|
|
|
Set the TSS thread descriptor. This method will call td->acquire_release to block execution until this call return. Definition at line 2266 of file Log_Msg.cpp. References ACE_Thread_Descriptor::acquire_release, and thr_desc_.
02267 {
02268 this->thr_desc_ = td;
02269
02270 if (td != 0)
02271 td->acquire_release ();
02272 }
|
|
|
Get the TSS thread descriptor.
Definition at line 2260 of file Log_Msg.cpp. References thr_desc_. Referenced by inherit_hook.
02261 {
02262 return this->thr_desc_;
02263 }
|
|
|
Return the TSS singleton thread descriptor.
Definition at line 492 of file Log_Msg.cpp. References ACE_LOG_MSG. Referenced by ACE_Log_Msg.
00493 {
00494 return ACE_LOG_MSG->thr_desc ();
00495 }
|
|
|
Get trace active status.
Definition at line 2254 of file Log_Msg.cpp. References trace_active_.
02255 {
02256 this->trace_active_ = value;
02257 }
|
|
|
Set trace active status.
Definition at line 2248 of file Log_Msg.cpp. References trace_active_. Referenced by ACE_Trace::ACE_Trace, and ACE_Trace::~ACE_Trace.
02249 {
02250 return this->trace_active_;
02251 }
|
|
|
Set trace depth.
Definition at line 2242 of file Log_Msg.cpp. References trace_depth_.
02243 {
02244 this->trace_depth_ = depth;
02245 }
|
|
|
Get trace depth.
Definition at line 2236 of file Log_Msg.cpp. References trace_depth_. Referenced by inherit_hook, and init_hook.
02237 {
02238 return this->trace_depth_;
02239 }
|
|
|
Query tracing status on a per-thread basis...
Definition at line 2317 of file Log_Msg.cpp. References tracing_enabled_. Referenced by ACE_Trace::ACE_Trace, init_hook, log, and ACE_Trace::~ACE_Trace.
02318 {
02319 return this->tracing_enabled_;
02320 }
|
|
|
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. |
|
|
Default per-thread priority mask By default, no priorities are enabled. Priority mask to use for each new instance Definition at line 426 of file Log_Msg.cpp. Referenced by disable_debug_messages, and enable_debug_messages. |
|
|
Are we deleting this ostream?
Definition at line 606 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 670 of file Log_Msg.h. Referenced by errnum. |
|
|
|
|
|
File where the error occurred.
Definition at line 579 of file Log_Msg.h. Referenced by file. |
|
|
Options flags used to hold the logger flag options, e.g., STDERR, LOGGER, OSTREAM, MSG_CALLBACK, etc.
Definition at line 416 of file Log_Msg.cpp. |
|
|
Instance count for Log_Msg - used to know when dynamically allocated storage (program name and host name) can be safely deleted. Number of existing ACE_Log_Msg instances; when 0, delete program/host names Definition at line 65 of file Log_Msg.cpp. Referenced by ACE_Log_Msg, and ~ACE_Log_Msg. |
|
|
|
|
|
|
|
|
Line number where the error occurred.
Definition at line 576 of file Log_Msg.h. Referenced by linenum. |
|
|
Name of the local host (used when printing messages).
Definition at line 410 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().
|
|
|
The callback object.
Definition at line 594 of file Log_Msg.h. Referenced by msg_callback. |
|
|
Offset of msg_[].
Definition at line 422 of file Log_Msg.cpp. |
|
|
|
|
|
The ostream where logging messages can be written.
Definition at line 591 of file Log_Msg.h. Referenced by msg_ostream, and ~ACE_Log_Msg. |
|
|
Process id of the current process.
Definition at line 419 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 621 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 Keeps track of all the per-process ACE_Log_Priority values that are currently enabled. Default is for all logging priorities to be enabled. Definition at line 430 of file Log_Msg.cpp. Referenced by log_priority_enabled, and priority_mask. |
|
|
Records the program name.
Definition at line 413 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.
Definition at line 588 of file Log_Msg.h. Referenced by restart. |
|
|
Status of operation (-1 means failure, >= 0 means success).
Definition at line 570 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. |
|
|
Are we already within an ACE_Trace constructor call?
Definition at line 600 of file Log_Msg.h. Referenced by trace_active. |
|
|
Depth of the nesting for printing traces.
Definition at line 597 of file Log_Msg.h. Referenced by dec, inc, log, and trace_depth. |
|
|
Are we allowing tracing in this thread?
Definition at line 603 of file Log_Msg.h. Referenced by start_tracing, stop_tracing, and tracing_enabled. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002