|
@@ -132,6 +132,42 @@ void log_trace(const char *fmt, ...);
|
|
|
*/
|
|
|
void log_session(const struct log_trace_session *session, const char *fmt, ...);
|
|
|
|
|
|
+extern void __logtrace_vfmtout(const struct log_trace_session *session,
|
|
|
+ const char *fmt,
|
|
|
+ va_list argptr);
|
|
|
+
|
|
|
+rt_inline void __logtrace_fmtout(const struct log_trace_session *session,
|
|
|
+ const char *fmt, ...)
|
|
|
+{
|
|
|
+ va_list args;
|
|
|
+
|
|
|
+ va_start(args, fmt);
|
|
|
+ __logtrace_vfmtout(session, fmt, args);
|
|
|
+ va_end(args);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * log with numeric level
|
|
|
+ *
|
|
|
+ * The prototype of this function is:
|
|
|
+ *
|
|
|
+ * void log_session_lvl(struct log_trace_session *session,
|
|
|
+ * int lvl,
|
|
|
+ * const char *fmt, ...);
|
|
|
+ *
|
|
|
+ * If the @session is const and @level is greater than @session->lvl, the whole
|
|
|
+ * function will be optimized out. This is suitable for performance critical
|
|
|
+ * places where in most cases, the log is turned off by level.
|
|
|
+ */
|
|
|
+#define log_session_lvl(session, level, fmt, ...) \
|
|
|
+ do { \
|
|
|
+ if ((level) > (session)->lvl) \
|
|
|
+ { \
|
|
|
+ break; \
|
|
|
+ } \
|
|
|
+ __logtrace_fmtout(session, fmt, ##__VA_ARGS__); \
|
|
|
+ } while (0)
|
|
|
+
|
|
|
/* here comes the global part. All sessions share the some output backend. */
|
|
|
|
|
|
/** get the backend device */
|