< prev index next >

src/share/vm/logging/logPrefix.hpp

Print this page

        

*** 31,57 **** // A prefix consists of a format string and a value or callback. Prefixes are added // after the decorations but before the log message. // // List of prefixes for specific tags and/or tagsets. // Syntax: LOG_PREFIX(<printf format>, <value/callback for value>, LOG_TAGS(<chosen log tags>)) ! #define LOG_PREFIX_LIST // Currently unused/empty // The empty prefix, used when there's no prefix defined. template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag = LogTag::__NO_TAG> struct LogPrefix : public AllStatic { STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); static size_t prefix(char* buf, size_t len) { return 0; } }; ! #define LOG_PREFIX(fmt, fn, ...) \ template <> struct LogPrefix<__VA_ARGS__> { \ static size_t prefix(char* buf, size_t len) { \ ! int ret = jio_snprintf(buf, len, fmt, fn); \ ! assert(ret >= 0, \ ! "Failed to prefix log message using prefix ('%s', '%s'), log buffer too small?", fmt, #fn); \ return ret; \ } \ }; LOG_PREFIX_LIST #undef LOG_PREFIX --- 31,85 ---- // A prefix consists of a format string and a value or callback. Prefixes are added // after the decorations but before the log message. // // List of prefixes for specific tags and/or tagsets. // Syntax: LOG_PREFIX(<printf format>, <value/callback for value>, LOG_TAGS(<chosen log tags>)) ! #define LOG_PREFIX_LIST \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, age)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, alloc)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, barrier)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, compaction)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, compaction, phases)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, cpu)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, conc)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, cset)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ergo, heap)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, heap)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, freelist)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, liveness)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, metaspace)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, start)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, plab)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, region)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, remset)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ref)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, ref, start)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, start)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, start)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, stats)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, task, time)) \ ! LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, tlab)) // The empty prefix, used when there's no prefix defined. template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag = LogTag::__NO_TAG> struct LogPrefix : public AllStatic { STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); static size_t prefix(char* buf, size_t len) { return 0; } }; ! #define LOG_PREFIX(fn, ...) \ template <> struct LogPrefix<__VA_ARGS__> { \ static size_t prefix(char* buf, size_t len) { \ ! DEBUG_ONLY(buf[0] = '\0'); \ ! size_t ret = fn(buf, len); \ ! assert(ret == strlen(buf), "Length mismatch ret (" SIZE_FORMAT ") != buf length (" SIZE_FORMAT ")", ret, strlen(buf)); \ return ret; \ } \ }; LOG_PREFIX_LIST #undef LOG_PREFIX
< prev index next >