00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Log_Msg.h 00006 * 00007 * Log_Msg.h,v 4.127 2006/04/25 06:32:10 jwillemsen Exp 00008 * 00009 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_LOG_MSG_H 00014 #define ACE_LOG_MSG_H 00015 #include /**/ "ace/pre.h" 00016 00017 // This stuff must come first to avoid problems with circular 00018 // headers... 00019 // ... but ACE_NDEBUG and ACE_NLOGGING can come from the config.h file, so 00020 // pull that one early. 00021 #include "ace/config-all.h" 00022 #include "ace/ACE_export.h" 00023 #include "ace/Global_Macros.h" 00024 #include "ace/Default_Constants.h" 00025 #include "ace/Log_Priority.h" 00026 #include "ace/os_include/os_limits.h" 00027 00028 // The ACE_ASSERT macro used to be defined here, include ace/Assert.h 00029 // for backwards compatibility. 00030 #include "ace/Assert.h" 00031 00032 #if defined (ACE_NLOGGING) 00033 #define ACE_HEX_DUMP(X) do {} while (0) 00034 #define ACE_RETURN(Y) do { return (Y); } while (0) 00035 #define ACE_ERROR_RETURN(X, Y) return (Y) 00036 #define ACE_ERROR_BREAK(X) { break; } 00037 #define ACE_ERROR(X) do {} while (0) 00038 #define ACE_DEBUG(X) do {} while (0) 00039 #define ACE_ERROR_INIT(VALUE, FLAGS) 00040 #else 00041 #define ACE_HEX_DUMP(X) \ 00042 do { \ 00043 int __ace_error = ACE_Log_Msg::last_error_adapter (); \ 00044 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00045 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ 00046 ace___->log_hexdump X; \ 00047 } while (0) 00048 #define ACE_RETURN(Y) \ 00049 do { \ 00050 int __ace_error = ACE_Log_Msg::last_error_adapter (); \ 00051 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00052 ace___->set (__FILE__, __LINE__, Y, __ace_error, ace___->restart (), \ 00053 ace___->msg_ostream (), ace___->msg_callback ()); \ 00054 return Y; \ 00055 } while (0) 00056 #define ACE_ERROR_RETURN(X, Y) \ 00057 do { \ 00058 int __ace_error = ACE_Log_Msg::last_error_adapter (); \ 00059 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00060 ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \ 00061 ace___->log X; \ 00062 return Y; \ 00063 } while (0) 00064 #define ACE_ERROR(X) \ 00065 do { \ 00066 int __ace_error = ACE_Log_Msg::last_error_adapter (); \ 00067 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00068 ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \ 00069 ace___->log X; \ 00070 } while (0) 00071 #define ACE_DEBUG(X) \ 00072 do { \ 00073 int __ace_error = ACE_Log_Msg::last_error_adapter (); \ 00074 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00075 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \ 00076 ace___->log X; \ 00077 } while (0) 00078 #define ACE_ERROR_INIT(VALUE, FLAGS) \ 00079 do { \ 00080 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ 00081 ace___->set_flags (FLAGS); ace___->op_status (VALUE); \ 00082 } while (0) 00083 #define ACE_ERROR_BREAK(X) { ACE_ERROR (X); break; } 00084 #endif /* ACE_NLOGGING */ 00085 00086 #include "ace/OS_Log_Msg_Attributes.h" 00087 00088 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00089 # pragma once 00090 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00091 00092 // These workarounds are necessary for nasty libraries or platforms 00093 // that #define STDERR or THREAD (e.g. LynxOS). We simply #undef 00094 // these macros as there is no way to save the macro definition using 00095 // the pre-processor. See Bugzilla Bug #299 for more info. 00096 00097 #if defined (STDERR) 00098 # undef STDERR 00099 #endif /* STDERR */ 00100 00101 #if defined (THREAD) 00102 # undef THREAD 00103 #endif /* THREAD */ 00104 00105 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00106 00107 class ACE_Log_Msg_Callback; 00108 class ACE_Log_Msg_Backend; 00109 00110 // **************************************************************** 00111 00112 #define ACE_LOG_MSG ACE_Log_Msg::instance () 00113 00114 // Forward declaration 00115 class ACE_Thread_Descriptor; 00116 class ACE_Log_Record; 00117 00118 /** 00119 * @class ACE_Log_Msg 00120 * 00121 * @brief Provides a variable length argument message logging 00122 * abstraction. 00123 * 00124 * This class is very flexible since it allows formatted error 00125 * messages to be printed in a thread-safe manner to various 00126 * locations, such as stdout, stderr, cerr, a distributed logger, etc. 00127 * The current message is also kept in a thread-specific storage 00128 * location (threads spawned using ACE_Thread_Manager automatically get 00129 * an ACE_Log_Msg object that inherits the spawning thread's settings), which 00130 * can be used to communicate errors between framework methods and 00131 * callers. A message is logged by the log() method, only if the 00132 * message priority is currently enabled. Moreover, only the current 00133 * log message is stored here -- it will be overwritten by the 00134 * subsequent call to log(). 00135 * 00136 * The ACE_Log_Msg class uses two priority masks to control its 00137 * logging behavior. The @c priority_mask_ object attribute is thread- 00138 * specific and specifies the priority levels logged by the thread. 00139 * The @c process_priority_mask_ class attribute is not thread-specific 00140 * and specifies the priority levels that will be logged by all 00141 * threads in the process. By default, all levels are disabled for 00142 * @c priority_mask_ and all levels are enabled for 00143 * @c process_priority_mask_ (i.e. the process-wide mask controls 00144 * the settings, and each instance can expand on it if desired). 00145 * Both priority masks can be modified using the priority_mask() 00146 * method of this class. 00147 */ 00148 class ACE_Export ACE_Log_Msg 00149 { 00150 00151 public: 00152 // Logger Flags. 00153 enum 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 }; 00177 00178 // = Initialization and termination routines. 00179 00180 /// Returns a pointer to the Singleton. 00181 static ACE_Log_Msg *instance (void); 00182 00183 /// Returns last error. 00184 static int last_error_adapter (void); 00185 00186 /// Returns non-null if an ACE_Log_Msg exists for the calling thread. 00187 static int exists (void); 00188 00189 /// Returns the current program name used for logging. 00190 static const ACE_TCHAR * program_name (void); 00191 /// Clears the flag from the default priority mask used to 00192 /// initialize ACE_Log_Msg instances. 00193 static void disable_debug_messages (ACE_Log_Priority priority = LM_DEBUG); 00194 00195 /// Sets the flag in the default priority mask used to initialize 00196 /// ACE_Log_Msg instances. 00197 static void enable_debug_messages (ACE_Log_Priority priority = LM_DEBUG); 00198 00199 /// Initialize logger. 00200 ACE_Log_Msg (void); 00201 00202 /// cleanup logger. 00203 ~ACE_Log_Msg (void); 00204 00205 /// Initialize the ACE logging facility. 00206 /** 00207 * Initialize the ACE logging facility. Supplies the program name 00208 * that is available to each logging message call. Default arguments 00209 * set up logging to STDERR only. 00210 * 00211 * @param prog_name The name of the calling program. 00212 * @param options_flags A bitwise-or of options flags used to set the 00213 * initial behavior and logging sink(s). (see the 00214 * enum above for the valid values). 00215 * @param logger_key The name of ACE_FIFO rendezvous point where the 00216 * local client logger daemon is listening for logging 00217 * messages if the LOGGER bit is set in the @a flags 00218 * argument. If the SYSLOG bit is set in @a flags, 00219 * @a logger_key is the source/program name specified 00220 * in the syslog facility (UNIX/Linux) or the Windows 00221 * event log (Windows). In the SYSLOG case, if 00222 * @a logger_key is 0, @a prog_name is used. 00223 */ 00224 int open (const ACE_TCHAR *prog_name, 00225 u_long options_flags = ACE_Log_Msg::STDERR, 00226 const ACE_TCHAR *logger_key = 0); 00227 00228 // = Set/get the options flags. 00229 00230 /** 00231 * Enable the bits in the logger's options flags. 00232 */ 00233 void set_flags (u_long f); 00234 00235 /** 00236 * Disable the bits in the logger's options flags. 00237 */ 00238 void clr_flags (u_long f); 00239 00240 /** 00241 * Return the bits in the logger's options flags. 00242 */ 00243 u_long flags (void); 00244 00245 /** @name Allow apps to acquire and release internal synchronization 00246 * lock 00247 * 00248 * This lock is used internally by the ACE_Log_Msg 00249 * implementation. By exporting the lock, applications can hold the 00250 * lock atomically over a number of calls to ACE_Log_Msg. 00251 */ 00252 //@{ 00253 00254 /// Acquire the internal lock. 00255 int acquire (void); 00256 00257 /// Release the internal lock. 00258 int release (void); 00259 //@} 00260 00261 /// Call after doing a @c fork() to resynchronize the process id and 00262 /// @c program_name_ variables. 00263 void sync (const ACE_TCHAR *program_name); 00264 00265 // = Set/get methods. Note that these are non-static and thus will 00266 // be thread-specific. 00267 00268 /// Set the result of the operation status (by convention, -1 means 00269 /// error). 00270 void op_status (int status); 00271 00272 /// Get the result of the operation status (by convention, -1 means 00273 /// error). 00274 int op_status (void); 00275 00276 /// Set the value of the errnum (by convention this corresponds to 00277 /// errno). 00278 void errnum (int); 00279 00280 /// Get the value of the errnum (by convention this corresponds to 00281 /// errno). 00282 int errnum (void); 00283 00284 /// Set the line number where an error occurred. 00285 void linenum (int); 00286 00287 /// Get the line number where an error occurred. 00288 int linenum (void); 00289 00290 /// Set the file name where an error occurred. 00291 void file (const char *); 00292 00293 /// Get the file name where an error occurred. 00294 const char *file (void); 00295 00296 /// Set the message that describes what type of error occurred. 00297 void msg (const ACE_TCHAR *); 00298 00299 /// Get the message that describes what type of error occurred. 00300 const ACE_TCHAR *msg (void); 00301 00302 /// Set the field that indicates whether interrupted calls should be 00303 /// restarted. 00304 void restart (int); 00305 00306 /// Get the field that indicates whether interrupted calls should be 00307 /// restarted. 00308 int restart (void); 00309 00310 // = Notice that the following two function is equivalent to 00311 // "void msg_ostream (HANDLE)" and "HANDLE msg_ostream (void)" 00312 // on Windows CE. There is no <iostream.h> support on CE. 00313 00314 /// Update the ostream without overwriting the delete_ostream_ flag. 00315 void msg_ostream (ACE_OSTREAM_TYPE *); 00316 00317 /** 00318 * delete_stream == 1, forces Log_Msg.h to delete the stream in 00319 * its own ~dtor (assumes control of the stream) 00320 * use only with proper ostream (eg: fstream), not (cout, cerr) 00321 */ 00322 void msg_ostream (ACE_OSTREAM_TYPE *, int delete_ostream); 00323 00324 /// Get the ostream that is used to print error messages. 00325 ACE_OSTREAM_TYPE *msg_ostream (void) const; 00326 00327 /** 00328 * Set a new callback object and return the existing callback to 00329 * allow "chaining". Note that ACE_Log_Msg_Callback objects are not 00330 * inherited when spawning a new thread, so you'll need to reset 00331 * them in each thread. 00332 */ 00333 ACE_Log_Msg_Callback *msg_callback (ACE_Log_Msg_Callback *c); 00334 ACE_Log_Msg_Callback *msg_callback (void) const; 00335 00336 /** 00337 * Set a new backend object and return the existing backend to 00338 * allow "chaining". Note that as opposed to ACE_Log_Msg_Callback, 00339 * ACE_Log_Msg_Backend is a per-process entity. 00340 * 00341 * @note Be aware that because of the current architecture there is 00342 * no guarantee that open (), reset () and close () will be called 00343 * on a backend object. 00344 * 00345 */ 00346 static ACE_Log_Msg_Backend *msg_backend (ACE_Log_Msg_Backend *b); 00347 static ACE_Log_Msg_Backend *msg_backend (void); 00348 00349 /// Nesting depth increment. 00350 int inc (void); 00351 00352 /// Nesting depth decrement. 00353 int dec (void); 00354 00355 /// Get trace depth. 00356 int trace_depth (void); 00357 00358 /// Set trace depth. 00359 void trace_depth (int); 00360 00361 /// Set trace active status. 00362 int trace_active (void); 00363 00364 /// Get trace active status. 00365 void trace_active (int value); 00366 00367 /// Get the TSS thread descriptor. 00368 ACE_Thread_Descriptor *thr_desc (void) const; 00369 00370 /** 00371 * Set the TSS thread descriptor. This method will call 00372 * td->acquire_release to block execution until this call 00373 * return. 00374 */ 00375 void thr_desc (ACE_Thread_Descriptor *td); 00376 00377 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) && defined(ACE_LEGACY_MODE) 00378 // These functions are disabled without ACE_LEGACY_MODE 00379 // because the *semantics* have changed (the objects are no longer 00380 // TSS). 00381 /// Get TSS exception action. 00382 /// @note The action is no longer TSS, they are global! 00383 ACE_SEH_EXCEPT_HANDLER seh_except_selector (void); 00384 00385 /// Set TSS exception action. 00386 /// @note The action is no longer TSS, they are global! 00387 ACE_SEH_EXCEPT_HANDLER seh_except_selector (ACE_SEH_EXCEPT_HANDLER); 00388 00389 /// Get TSS exception handler. 00390 /// @note The handler is no longer TSS, they are global! 00391 ACE_SEH_EXCEPT_HANDLER seh_except_handler (void); 00392 00393 /// Set TSS exception handler. 00394 /// @note The handler is no longer TSS, they are global! 00395 ACE_SEH_EXCEPT_HANDLER seh_except_handler (ACE_SEH_EXCEPT_HANDLER); 00396 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS && ACE_LEGACY_MODE */ 00397 00398 /// Stop tracing status on a per-thread basis... 00399 void stop_tracing (void); 00400 00401 /// Start tracing status on a per-thread basis... 00402 void start_tracing (void); 00403 00404 /// Query tracing status on a per-thread basis... 00405 int tracing_enabled (void); 00406 00407 typedef enum 00408 { 00409 PROCESS = 0, 00410 THREAD = 1 00411 } MASK_TYPE; 00412 00413 // = Get/set the priority mask. 00414 /// Get the current ACE_Log_Priority mask. 00415 u_long priority_mask (MASK_TYPE = THREAD); 00416 00417 /// Set the ACE_Log_Priority mask, returns original mask. 00418 u_long priority_mask (u_long, MASK_TYPE = THREAD); 00419 00420 /// Return true if the requested priority is enabled. 00421 int log_priority_enabled (ACE_Log_Priority log_priority); 00422 00423 /// Return true if the requested priority is enabled. 00424 int log_priority_enabled (ACE_Log_Priority log_priority, 00425 const char *, 00426 ...); 00427 00428 #if defined (ACE_USES_WCHAR) 00429 // We are not using ACE_TCHAR for this since ACE_HEX_DUMP 00430 // doesn't take in a ACE_TCHAR. log_hexdump takes in a char 00431 // string, so this must be able to take in a char string even 00432 // when using ACE_USES_WCHAR. 00433 /// Return true if the requested priority is enabled. 00434 int log_priority_enabled (ACE_Log_Priority log_priority, 00435 const wchar_t *, 00436 ...); 00437 #endif /* ACE_USES_WCHAR */ 00438 00439 /// Optimize reading of the pid (avoids a system call if the value is 00440 /// cached...). 00441 pid_t getpid (void) const; 00442 00443 /// Get the name of the local host. 00444 const ACE_TCHAR *local_host (void) const; 00445 00446 /// Set the name of the local host. 00447 void local_host (const ACE_TCHAR *); 00448 00449 /** 00450 * Set the line number, file name, operational status, error number, 00451 * restart flag, ostream, and the callback object. This combines 00452 * all the other set methods into a single method. 00453 */ 00454 void set (const char *file, 00455 int line, 00456 int op_status = -1, 00457 int errnum = 0, 00458 int restart = 1, 00459 ACE_OSTREAM_TYPE *os = 0, 00460 ACE_Log_Msg_Callback *c = 0); 00461 00462 /// These values are only actually set if the requested priority is 00463 /// enabled. 00464 void conditional_set (const char *file, 00465 int line, 00466 int op_status, 00467 int errnum); 00468 00469 /** 00470 * Format a message to the thread-safe ACE logging mechanism. Valid 00471 * options (prefixed by '%', as in printf format strings) include: 00472 * - 'A': print an ACE_timer_t value (which could be either double 00473 * or ACE_UINT32.) 00474 * - 'a': abort the program at this point abruptly. 00475 * - 'c': print a character 00476 * - 'C': print a character string 00477 * - 'i', 'd': print a decimal number 00478 * - 'I': indent according to nesting depth (obtained from 00479 * ACE_Trace::get_nesting_indent()). 00480 * - 'e', 'E', 'f', 'F', 'g', 'G': print a double 00481 * - 'l': print line number where an error occurred. 00482 * - 'M': print the name of the priority of the message. 00483 * - 'm': return the message corresponding to errno value, e.g., as 00484 * done by strerror() 00485 * - 'N': print file name where the error occurred. 00486 * - 'n': print the name of the program (or "<unknown>" if not set) 00487 * - 'o': print as an octal number 00488 * - 'P': print out the current process id 00489 * - 'p': print out the appropriate errno message from sys_errlist, 00490 * e.g., as done by perror() 00491 * - 'Q': print out the uint64 number 00492 * - 'q': print out the int64 number 00493 * - '@': print a void* pointer (in hexadecimal) 00494 * - 'r': call the function pointed to by the corresponding argument 00495 * - 'R': print return status 00496 * - 'S': print out the appropriate _sys_siglist entry corresponding 00497 * to var-argument. 00498 * - 's': print out a character string 00499 * - 'T': print timestamp in hour:minute:sec:usec format. 00500 * - 'D': print timestamp in month/day/year hour:minute:sec:usec format. 00501 * - 't': print thread id (1 if single-threaded) 00502 * - 'u': print as unsigned int 00503 * - 'w': prints a wide character 00504 * - 'W': print a wide character string 00505 * - 'x': print as a hex number 00506 * - 'X': print as a hex number 00507 * - 'z': print an ACE_OS::WChar character 00508 * - 'Z': print an ACE_OS::WChar character string 00509 * - '%': print out a single percent sign, '%' 00510 */ 00511 ssize_t log (ACE_Log_Priority priority, const ACE_TCHAR *format, ...); 00512 00513 #if defined (ACE_HAS_WCHAR) 00514 ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...); 00515 #endif /* ACE_HAS_WCHAR */ 00516 00517 /** 00518 * An alternative logging mechanism that makes it possible to 00519 * integrate variable argument lists from other logging mechanisms 00520 * into the ACE mechanism. 00521 */ 00522 ssize_t log (const ACE_TCHAR *format, 00523 ACE_Log_Priority priority, 00524 va_list argp); 00525 00526 /// Log a custom built log record to the currently enabled logging 00527 /// sinks. 00528 ssize_t log (ACE_Log_Record &log_record, 00529 int suppress_stderr = 0); 00530 00531 /** 00532 * Method to log hex dump. This is useful for debugging. Calls 00533 * log() to do the actual print, but formats first to make the chars 00534 * printable. 00535 */ 00536 int log_hexdump (ACE_Log_Priority log_priority, 00537 const char *buffer, 00538 size_t size, 00539 const ACE_TCHAR *text = 0); 00540 00541 static void init_hook (ACE_OS_Log_Msg_Attributes &attributes 00542 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) 00543 , ACE_SEH_EXCEPT_HANDLER selector = 0 00544 , ACE_SEH_EXCEPT_HANDLER handler = 0 00545 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ 00546 /** 00547 * Init hook, create a Log_Msg_Attribute object, initialize its 00548 * attributes from the TSS Log_Msg and save the object in the 00549 * @a attributes argument 00550 */ 00551 ); 00552 00553 /** 00554 * Inherit hook, the @a attributes field is a ACE_OS_Log_Msg_Attributes 00555 * object, invoke the inherit_log_msg() method on it, then destroy 00556 * it and set the @a attribute argument to 0. 00557 */ 00558 static void inherit_hook (ACE_OS_Thread_Descriptor *thr_desc, 00559 ACE_OS_Log_Msg_Attributes &attributes); 00560 00561 /// Dump the state of an object. 00562 void dump (void) const; 00563 00564 /// Declare the dynamic allocation hooks. 00565 ACE_ALLOC_HOOK_DECLARE; 00566 00567 private: 00568 /// Status of operation (-1 means failure, >= 0 means success). 00569 int status_; 00570 00571 /// Type of error that occurred (see <sys/errno.h>). 00572 int errnum_; 00573 00574 /// Line number where the error occurred. 00575 int linenum_; 00576 00577 /// File where the error occurred. 00578 char file_[MAXPATHLEN + 1]; 00579 00580 /// The log message, which resides in thread-specific storage. Note 00581 /// that only the current log message is stored here -- it will be 00582 /// overwritten by the subsequent call to log(). 00583 ACE_TCHAR* msg_; // Add one for NUL-terminator. 00584 00585 /// Indicates whether we should restart system calls that are 00586 /// interrupted. 00587 int restart_; 00588 00589 /// The ostream where logging messages can be written. 00590 ACE_OSTREAM_TYPE *ostream_; 00591 00592 /// The callback object. 00593 ACE_Log_Msg_Callback *msg_callback_; 00594 00595 /// Depth of the nesting for printing traces. 00596 int trace_depth_; 00597 00598 /// Are we already within an ACE_Trace constructor call? 00599 int trace_active_; 00600 00601 /// Are we allowing tracing in this thread? 00602 int tracing_enabled_; 00603 00604 /// Are we deleting this ostream? 00605 int delete_ostream_; 00606 00607 /** 00608 * If we're running in the context of an ACE_Thread_Manager this 00609 * will point to the thread descriptor adapter which holds the 00610 * thread descriptor of the thread. This can be used to repidly 00611 * access all thread data kept in ACE_Thread_Descriptor. 00612 */ 00613 ACE_Thread_Descriptor *thr_desc_; 00614 00615 /** 00616 * Keeps track of all the per-thread ACE_Log_Priority values that 00617 * are currently enabled. Default is for all logging priorities to 00618 * be disabled. 00619 */ 00620 u_long priority_mask_; 00621 00622 /// Always timestamp? 00623 int timestamp_; 00624 00625 // = The following fields are *not* kept in thread-specific storage. 00626 00627 // We only want one instance for the entire process! 00628 00629 /** 00630 * Keeps track of all the per-process ACE_Log_Priority values that 00631 * are currently enabled. Default is for all logging priorities to 00632 * be enabled. 00633 */ 00634 static u_long process_priority_mask_; 00635 00636 /// Records the program name. 00637 static const ACE_TCHAR *program_name_; 00638 00639 /// Name of the local host (used when printing messages). 00640 static const ACE_TCHAR *local_host_; 00641 00642 /// Process id of the current process. 00643 static pid_t pid_; 00644 00645 /// Options flags used to hold the logger flag options, e.g., 00646 /// STDERR, LOGGER, OSTREAM, MSG_CALLBACK, etc. 00647 static u_long flags_; 00648 00649 /// Offset of msg_[]. 00650 static long msg_off_; 00651 00652 /** 00653 * Number of existing ACE_Log_Msg instances; when 0, delete program/host 00654 * names 00655 */ 00656 static int instance_count_; 00657 00658 /** 00659 * Priority mask to use for each new instance 00660 */ 00661 static u_long default_priority_mask_; 00662 00663 /// Anonymous struct since there will only be one instance. This 00664 /// struct keeps information stored away in case we actually end up 00665 /// calling log() if the log priority is correct. 00666 struct 00667 { 00668 int is_set_; 00669 const char *file_; 00670 int line_; 00671 int op_status_; 00672 int errnum_; 00673 } conditional_values_; 00674 00675 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00676 static int key_created_; 00677 #endif /* ACE_MT_SAFE */ 00678 00679 /// For cleanup, at program termination. 00680 static void close (void); 00681 00682 /// Decouple the OS layer from the ACE_Log_Msg layer. 00683 static void sync_hook (const ACE_TCHAR *prg_name); 00684 00685 /// Return the TSS singleton thread descriptor 00686 static ACE_OS_Thread_Descriptor *thr_desc_hook (void); 00687 00688 //friend void ACE_OS::cleanup_tss (const u_int); 00689 00690 // = Disallow these operations. 00691 ACE_Log_Msg &operator= (const ACE_Log_Msg &); 00692 ACE_Log_Msg (const ACE_Log_Msg &); 00693 }; 00694 00695 ACE_END_VERSIONED_NAMESPACE_DECL 00696 00697 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00698 # if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \ 00699 defined (ACE_HAS_TSS_EMULATION) 00700 /* static */ 00701 # if defined (ACE_HAS_THR_C_DEST) 00702 # define LOCAL_EXTERN_PREFIX extern "C" 00703 # else 00704 # define LOCAL_EXTERN_PREFIX 00705 # endif /* ACE_HAS_THR_C_DEST */ 00706 00707 #if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) 00708 # define ACE_TSS_CLEANUP_NAME ACE_PREPROC_CONCATENATE(ACE_,ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _TSS_cleanup)) 00709 #else 00710 # define ACE_TSS_CLEANUP_NAME ACE_TSS_cleanup 00711 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ 00712 00713 00714 LOCAL_EXTERN_PREFIX 00715 void 00716 ACE_TSS_CLEANUP_NAME (void *ptr); 00717 # endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ 00718 #endif /* ACE_MT_SAFE */ 00719 00720 #if defined(ACE_LEGACY_MODE) 00721 #include "ace/Log_Msg_Callback.h" 00722 #endif /* ACE_LEGACY_MODE */ 00723 00724 #include /**/ "ace/post.h" 00725 #endif /* ACE_LOG_MSG_H */