summaryrefslogtreecommitdiff
path: root/lib/igt_core.h
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2014-12-02 10:54:54 +0000
committerThomas Wood <thomas.wood@intel.com>2014-12-11 17:55:15 +0000
commit8161a21762b552d97fe6bde8d4fd441d9cd10f61 (patch)
treeddab7ee124f986af4451508c44890c2ce87bc4c1 /lib/igt_core.h
parent85b74d5c14506bbae53ab02408102645e071a206 (diff)
lib: introduce log domains
Log domains can be used to identify the source of log messages, such as the test being run or the helper library. v2: Add separate domains for different parts of the helper library and use an empty default domain for applications. Expand the log output to include the process name and the log level of the message in addition to the domain and pid. Print the expanded message only for warning and debug messages. v3: check for glibc before using program_invocation_short_name Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r--lib/igt_core.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h
index a2583488..5c5ee255 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -512,16 +512,20 @@ bool igt_run_in_simulation(void);
void igt_skip_on_simulation(void);
/* structured logging */
+#ifndef IGT_LOG_DOMAIN
+#define IGT_LOG_DOMAIN (NULL)
+#endif
+
enum igt_log_level {
IGT_LOG_DEBUG,
IGT_LOG_INFO,
IGT_LOG_WARN,
IGT_LOG_NONE,
};
-__attribute__((format(printf, 2, 3)))
-void igt_log(enum igt_log_level level, const char *format, ...);
-__attribute__((format(printf, 2, 0)))
-void igt_vlog(enum igt_log_level level, const char *format, va_list args);
+__attribute__((format(printf, 3, 4)))
+void igt_log(const char *domain, enum igt_log_level level, const char *format, ...);
+__attribute__((format(printf, 3, 0)))
+void igt_vlog(const char *domain, enum igt_log_level level, const char *format, va_list args);
/**
* igt_debug:
@@ -529,7 +533,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args);
*
* Wrapper for igt_log() for message at the IGT_LOG_DEBUG level.
*/
-#define igt_debug(f...) igt_log(IGT_LOG_DEBUG, f)
+#define igt_debug(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_DEBUG, f)
/**
* igt_info:
@@ -537,7 +541,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args);
*
* Wrapper for igt_log() for message at the IGT_LOG_INFO level.
*/
-#define igt_info(f...) igt_log(IGT_LOG_INFO, f)
+#define igt_info(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_INFO, f)
/**
* igt_warn:
@@ -545,7 +549,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args);
*
* Wrapper for igt_log() for message at the IGT_LOG_WARN level.
*/
-#define igt_warn(f...) igt_log(IGT_LOG_WARN, f)
+#define igt_warn(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_WARN, f)
extern enum igt_log_level igt_log_level;
/**