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