< prev index next >
src/share/vm/logging/log.hpp
Print this page
rev 8933 : 8046148.01
*** 21,34 ****
--- 21,36 ----
* questions.
*
*/
#ifndef SHARE_VM_LOGGING_LOG_HPP
#define SHARE_VM_LOGGING_LOG_HPP
+
#include "logging/logLevel.hpp"
#include "logging/logPrefix.hpp"
#include "logging/logTagSet.hpp"
#include "logging/logTag.hpp"
+ #include "memory/allocation.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
//
// Logging macros
*** 71,82 ****
// obj->print_on(log.debug_stream());
// }
//
#define LogHandle(...) Log<LOG_TAGS(__VA_ARGS__)>
! template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG, LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
! class Log {
private:
static const size_t LogBufferSize = 512;
public:
// Make sure no more than the maximum number of tags have been given.
// The GuardTag allows this to be detected if/when it happens. If the GuardTag
--- 73,85 ----
// obj->print_on(log.debug_stream());
// }
//
#define LogHandle(...) Log<LOG_TAGS(__VA_ARGS__)>
! template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
! LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
! class Log VALUE_OBJ_CLASS_SPEC {
private:
static const size_t LogBufferSize = 512;
public:
// Make sure no more than the maximum number of tags have been given.
// The GuardTag allows this to be detected if/when it happens. If the GuardTag
*** 86,99 ****
static bool is_level(LogLevelType level) {
return LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().is_level(level);
}
template <LogLevelType Level>
! static void write(const char* fmt, ...) ATTRIBUTE_PRINTF(1, 2);
template <LogLevelType Level>
! static void vwrite(const char* fmt, va_list args) ATTRIBUTE_PRINTF(1, 0);
#define LOG_LEVEL(level, name) ATTRIBUTE_PRINTF(2, 0) \
Log& v##name(const char* fmt, va_list args) { \
vwrite<LogLevel::level>(fmt, args); \
return *this; \
--- 89,120 ----
static bool is_level(LogLevelType level) {
return LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().is_level(level);
}
template <LogLevelType Level>
! ATTRIBUTE_PRINTF(1, 2)
! static void write(const char* fmt, ...) {
! va_list args;
! va_start(args, fmt);
! vwrite<Level>(fmt, args);
! va_end(args);
! };
!
! template <LogLevelType Level>
! ATTRIBUTE_PRINTF(1, 0)
! static void vwrite(const char* fmt, va_list args) {
! char buf[LogBufferSize];
! size_t prefix_len = LogPrefix<T0, T1, T2, T3, T4>::prefix(buf, sizeof(buf));
! int ret = vsnprintf(buf + prefix_len, sizeof(buf) - prefix_len, fmt, args);
! assert(ret >= 0 && (size_t)ret < sizeof(buf), "Log message too long");
! puts<Level>(buf);
! }
template <LogLevelType Level>
! static void puts(const char* string) {
! LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().log(Level, string);
! }
#define LOG_LEVEL(level, name) ATTRIBUTE_PRINTF(2, 0) \
Log& v##name(const char* fmt, va_list args) { \
vwrite<LogLevel::level>(fmt, args); \
return *this; \
*** 113,137 ****
}
LOG_LEVEL_LIST
#undef LOG_LEVEL
};
! template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
! template <LogLevelType Level>
! void Log<T0, T1, T2, T3, T4, GuardTag>::write(const char* fmt, ...) {
! va_list args;
! va_start(args, fmt);
! vwrite<Level>(fmt, args);
! va_end(args);
! }
!
! template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
! template <LogLevelType Level>
! void Log<T0, T1, T2, T3, T4, GuardTag>::vwrite(const char* fmt, va_list args) {
! char buf[LogBufferSize];
! size_t prefix_len = LogPrefix<T0, T1, T2, T3, T4>::prefix(buf, sizeof(buf));
! int ret = vsnprintf(buf + prefix_len, sizeof(buf) - prefix_len, fmt, args);
! assert(ret >= 0 && (size_t)ret < sizeof(buf), "Log message too long");
! LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().log(Level, buf);
! }
!
! #endif
--- 134,139 ----
}
LOG_LEVEL_LIST
#undef LOG_LEVEL
};
! #endif // SHARE_VM_LOGGING_LOG_HPP
< prev index next >