diff options
author | huangming <huangminghuang@users.noreply.github.com> | 2004-02-13 17:48:40 +0000 |
---|---|---|
committer | huangming <huangminghuang@users.noreply.github.com> | 2004-02-13 17:48:40 +0000 |
commit | 6c762aef929a4942c3f3e3d96ae43e6f95585e55 (patch) | |
tree | e694e8889676e14ca099fd24bf14e3e1ea5ac266 | |
parent | e901c16deccb59d59f68a9827e4017e45413290e (diff) | |
download | ATCD-6c762aef929a4942c3f3e3d96ae43e6f95585e55.tar.gz |
ChangeLogEntry:
-rw-r--r-- | TAO/ChangeLog | 1 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp | 25 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h | 44 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl | 45 |
4 files changed, 115 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 357cea7bab0..e41ee2d44b9 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,4 @@ + Fri Feb 13 11:18:21 2004 Huang-Ming Huang <hh1@cse.wustl.edu> * orbsvcs/FTRT_Event_Service/Event_Service/svc.conf: diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp new file mode 100644 index 00000000000..a5e7970c995 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.cpp @@ -0,0 +1,25 @@ +//$Id$ +#include "Log.h" + +#if !defined(__ACE_INLINE__) +#include "Log.inl" +#endif /* __ACE_INLINE__ */ + +namespace TAO_FTRTEC { + +unsigned int Log::log_level_; + +#ifndef NDEBUG + Log::Log (unsigned int log_level, const ACE_TCHAR* format, ...) + { + if (log_level_ >= log_level) { + va_list p; + va_start(p, format); + char str[1024]; + ACE_OS::vsprintf(str, format, p); + ACE_DEBUG((LM_DEBUG, str)); + va_end(p); + } + } +#endif +} diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h new file mode 100644 index 00000000000..8c5cea58973 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Log.h + * + * $Id$ + * + * @author Huang-Ming Huang <hh1@cse.wustl.edu> + */ +//============================================================================= +#ifndef FTRTEC_LOG_H +#define FTRTEC_LOG_H + +#include /**/ "ace/pre.h" +#include "ftrtevent_export.h" +#include "ace/OS.h" +#include "ace/Log_Msg.h" + +namespace TAO_FTRTEC { + + /** + * A utility class for logging messages. + */ + class TAO_FtRtEvent_Export Log + { + public: + Log (unsigned int log_level, const ACE_TCHAR* format, ...); + static void level(unsigned int log_level); + static unsigned int level(); + static void hexdump(unsigned int log_level, const char* buf, size_t len, const char* msg); + private: + friend class Trace; + static unsigned log_level_; + }; +} + +#define FTRTEC_TRACE(x) TAO_FTRTEC::Trace __ftrtec_trace_obj(x) +#define FTRTEC_LOGTIME(x) TAO_FTRTEC::TimeAutoLogger __ftrtec_time_logger(x) +#if defined(__ACE_INLINE__) +#include "Log.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl new file mode 100644 index 00000000000..b35e1a5a432 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl @@ -0,0 +1,45 @@ +// $Id$ + +namespace TAO_FTRTEC { +#ifndef NDEBUG + ACE_INLINE + void Log::level(unsigned int log_level) + { + log_level_ = log_level; + } + + ACE_INLINE + unsigned int Log::level() + { + return log_level_; + } + + ACE_INLINE + void Log::hexdump(unsigned int level, const char* buf, size_t len, const char* msg) + { + if (Log::log_level_ >= level) + ACE_HEX_DUMP((LM_DEBUG, buf, len, msg)); + } +#else // NDEBUG + ACE_INLINE + Log::Log (unsigned int, const ACE_TCHAR*, ...) + { + } + + ACE_INLINE + void Log::level(unsigned int ) + { + } + + ACE_INLINE + unsigned int Log::level() + { + return 0; + } + + ACE_INLINE + void Log::hexdump(unsigned int, const char*, size_t, const char*) + { + } +#endif +} |