93 // The class provides a way to write the tags and log level once,
94 // so that redundant specification of tags or levels can be avoided.
95 //
96 // Example usage:
97 // LogTarget(Debug, gc) out;
98 // if (out.is_enabled()) {
99 // ...
100 // out.print("Worker: %u", i);
101 // out.print(" data: %d", x);
102 // ...
103 // print_stats(out.stream());
104 // }
105 //
106 #define LogTarget(level, ...) LogTargetImpl<LogLevel::level, LOG_TAGS(__VA_ARGS__)>
107
108 template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
109 class LogTargetImpl;
110
111 template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
112 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
113 class LogImpl VALUE_OBJ_CLASS_SPEC {
114 private:
115 static const size_t LogBufferSize = 512;
116 public:
117 // Make sure no more than the maximum number of tags have been given.
118 // The GuardTag allows this to be detected if/when it happens. If the GuardTag
119 // is not __NO_TAG, the number of tags given exceeds the maximum allowed.
120 STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); // Number of logging tags exceeds maximum supported!
121
122 // Empty constructor to avoid warnings on MSVC about unused variables
123 // when the log instance is only used for static functions.
124 LogImpl() {
125 }
126
127 static bool is_level(LogLevelType level) {
128 return LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().is_level(level);
129 }
130
131 ATTRIBUTE_PRINTF(2, 3)
132 static void write(LogLevelType level, const char* fmt, ...) {
133 va_list args;
|
93 // The class provides a way to write the tags and log level once,
94 // so that redundant specification of tags or levels can be avoided.
95 //
96 // Example usage:
97 // LogTarget(Debug, gc) out;
98 // if (out.is_enabled()) {
99 // ...
100 // out.print("Worker: %u", i);
101 // out.print(" data: %d", x);
102 // ...
103 // print_stats(out.stream());
104 // }
105 //
106 #define LogTarget(level, ...) LogTargetImpl<LogLevel::level, LOG_TAGS(__VA_ARGS__)>
107
108 template <LogLevelType level, LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
109 class LogTargetImpl;
110
111 template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
112 LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG>
113 class LogImpl {
114 private:
115 static const size_t LogBufferSize = 512;
116 public:
117 // Make sure no more than the maximum number of tags have been given.
118 // The GuardTag allows this to be detected if/when it happens. If the GuardTag
119 // is not __NO_TAG, the number of tags given exceeds the maximum allowed.
120 STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); // Number of logging tags exceeds maximum supported!
121
122 // Empty constructor to avoid warnings on MSVC about unused variables
123 // when the log instance is only used for static functions.
124 LogImpl() {
125 }
126
127 static bool is_level(LogLevelType level) {
128 return LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().is_level(level);
129 }
130
131 ATTRIBUTE_PRINTF(2, 3)
132 static void write(LogLevelType level, const char* fmt, ...) {
133 va_list args;
|