diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-27 03:22:57 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-27 03:22:57 +0000 |
commit | 016e8926a603229b6da449d70d127fdae243b35d (patch) | |
tree | 3ea5c0fc1451d848844f371331c3e0b620a64578 /ace | |
parent | ae733d2b055b8bcdb3654addb3ab4944d78089a3 (diff) | |
download | ATCD-016e8926a603229b6da449d70d127fdae243b35d.tar.gz |
added support for -d in Service_Config files to enable/disable LM_DEBUG messages
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Log_Msg.cpp | 37 | ||||
-rw-r--r-- | ace/Log_Msg.h | 31 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 3 |
3 files changed, 47 insertions, 24 deletions
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 7269e642379..48e92c57d35 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -241,6 +241,17 @@ ACE_Log_Msg::instance (void) } #undef ACE_NEW_RETURN_I +void +ACE_Log_Msg::disable_debug_messages() + // Clears the LM_DEBUG flag from the default priority mask used to + // initialise ACE_Log_Msg instances, as well as the current instance. +{ + default_priority_mask_ &= ~LM_DEBUG; + ACE_Log_Msg *currentInstance = ACE_Log_Msg::instance(); + currentInstance->priority_mask(currentInstance->priority_mask() & +~LM_DEBUG); +} + // Name of the local host. const ASYS_TCHAR *ACE_Log_Msg::local_host_ = 0; @@ -256,6 +267,20 @@ pid_t ACE_Log_Msg::pid_ = -1; // Current offset of msg_[]. int ACE_Log_Msg::msg_off_ = 0; +// Default priority mask +// By default, all priorities are enabled. +u_long ACE_Log_Msg::default_priority_mask_ = LM_SHUTDOWN + | LM_TRACE + | LM_DEBUG + | LM_INFO + | LM_NOTICE + | LM_WARNING + | LM_STARTUP + | LM_ERROR + | LM_CRITICAL + | LM_ALERT + | LM_EMERGENCY; + void ACE_Log_Msg::close (void) { @@ -374,17 +399,7 @@ ACE_Log_Msg::ACE_Log_Msg (void) trace_active_ (0), tracing_enabled_ (1), // On by default? thr_desc_ (0), - priority_mask_ (LM_SHUTDOWN // By default, all priorities are enabled. - | LM_TRACE - | LM_DEBUG - | LM_INFO - | LM_NOTICE - | LM_WARNING - | LM_STARTUP - | LM_ERROR - | LM_CRITICAL - | LM_ALERT - | LM_EMERGENCY) + priority_mask_ (default_priority_mask_) { // ACE_TRACE ("ACE_Log_Msg::ACE_Log_Msg"); diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h index 6c6d3a22f85..cbd0931044e 100644 --- a/ace/Log_Msg.h +++ b/ace/Log_Msg.h @@ -23,16 +23,16 @@ // The following ASSERT macro is courtesy of Alexandre Karev // <akg@na47sun05.cern.ch>. #if defined (ACE_NDEBUG) -#define ACE_ASSERT(x) +#define ACE_ASSERT(x) #else -#define ACE_ASSERT(X) \ +#define ACE_ASSERT(X) \ do { if(!(X)) { \ int __ace_error = ACE_OS::last_error (); \ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ ace___->set (ASYS_TEXT (__FILE__), __LINE__, -1, __ace_error, ace___->restart (), ace___->msg_ostream ()); \ ace___->log (LM_ERROR, ASYS_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), ASYS_WIDE_STRING (#X), -1); \ } } while (0) -#endif /* ACE_NDEBUG */ +#endif /* ACE_NDEBUG */ #if defined (ACE_NLOGGING) #define ACE_HEX_DUMP(X) @@ -140,6 +140,9 @@ public: static int exists (void); // Returns non-null if an ACE_Log_Msg exists for the calling thread. + static void disable_debug_messages(); + // Clears the LM_DEBUG flag from the default priority mask used to + // initialise ACE_Log_Msg instances. ACE_Log_Msg (void); // Initialize logger. @@ -147,8 +150,8 @@ public: // cleanup logger. int open (const ASYS_TCHAR *prog_name, - u_long options_flags = ACE_Log_Msg::STDERR, - LPCTSTR logger_key = 0); + u_long options_flags = ACE_Log_Msg::STDERR, + LPCTSTR logger_key = 0); // Initialize the ACE error handling facility. <prog_name> is the // name of the executable program. <flags> are a bitwise-or of // options flags passed to the Logger (see the enum above for the valid @@ -278,11 +281,11 @@ public: void local_host (const ASYS_TCHAR *); void set (const ASYS_TCHAR *file, - int line, - int op_status = -1, - int errnum = 0, - int restart = 1, - ostream *os = 0); + int line, + int op_status = -1, + int errnum = 0, + int restart = 1, + ostream *os = 0); // Set the line number, file name, operational status, error number, // restart flag, and ostream. This combines all the other set // methods into a single method. @@ -325,9 +328,9 @@ public: // sinks. int log_hexdump (ACE_Log_Priority log_priority, - const char *buffer, - int size, - const ASYS_TCHAR *text = 0); + const char *buffer, + int size, + const ASYS_TCHAR *text = 0); // 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. @@ -403,6 +406,8 @@ private: static int instance_count_; // Number of existing Log_Msg instances; when 0, delete program/host // names + static u_long default_priority_mask_; + // Priority mask to use for each new instance static void close (void); // For cleanup, at program termination. diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index a2730e2debc..cf4acb76967 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -461,6 +461,9 @@ ACE_Service_Config::open (const ASYS_TCHAR program_name[], { ACE_TRACE ("ACE_Service_Config::open"); + // Clear the LM_DEBUG bit from log messages if appropriate + if (!ACE_Service_Config::debug_) + ACE_Log_Msg::disable_debug_messages(); // Become a daemon before doing anything else. if (ACE_Service_Config::be_a_daemon_) ACE_Service_Config::start_daemon (); |