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