summaryrefslogtreecommitdiffstats
path: root/daemons/ipa-slapi-plugins/common/util.h
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-11-03 14:44:44 +0100
committerSimo Sorce <ssorce@redhat.com>2010-11-22 16:01:35 -0500
commit5da451876e76fa8bfc04a537d30c2d3c5ef84841 (patch)
tree4eae2286dbba4424b3d0f54888c6c51efca87ad3 /daemons/ipa-slapi-plugins/common/util.h
parentb9f539ba19b40361265c7897a73a1f5757ed0e68 (diff)
downloadfreeipa-5da451876e76fa8bfc04a537d30c2d3c5ef84841.tar.gz
freeipa-5da451876e76fa8bfc04a537d30c2d3c5ef84841.tar.xz
freeipa-5da451876e76fa8bfc04a537d30c2d3c5ef84841.zip
Common include file for SLAPI plugin logging
Consolidate the common logging macros into common/util.h and use them in SLAPI plugins instead of calling slapi_log_error() directly. https://fedorahosted.org/freeipa/ticket/408 Signed-off-by: Simo Sorce <ssorce@redhat.com>
Diffstat (limited to 'daemons/ipa-slapi-plugins/common/util.h')
-rw-r--r--daemons/ipa-slapi-plugins/common/util.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/daemons/ipa-slapi-plugins/common/util.h b/daemons/ipa-slapi-plugins/common/util.h
new file mode 100644
index 00000000..00571db5
--- /dev/null
+++ b/daemons/ipa-slapi-plugins/common/util.h
@@ -0,0 +1,39 @@
+#ifndef _SLAPI_PLUGINS_UTIL_H
+#define _SLAPI_PLUGINS_UTIL_H
+
+#define EOK 0
+#define EFAIL -1
+
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#define log_func discard_const(__func__)
+
+#define LOG_PLUGIN_NAME(NAME, fmt, ...) \
+ slapi_log_error(SLAPI_LOG_PLUGIN, \
+ NAME, \
+ fmt, ##__VA_ARGS__)
+
+#define LOG(fmt, ...) \
+ LOG_PLUGIN_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
+
+#define LOG_CONFIG_NAME(NAME, fmt, ...) \
+ slapi_log_error(SLAPI_LOG_CONFIG, \
+ NAME, \
+ fmt, ##__VA_ARGS__)
+
+#define LOG_CONFIG(fmt, ...) \
+ LOG_CONFIG_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
+
+#define LOG_FATAL(fmt, ...) \
+ slapi_log_error(SLAPI_LOG_FATAL, log_func, \
+ "[file %s, line %d]: " fmt, \
+ __FILE__, __LINE__, ##__VA_ARGS__)
+
+#define LOG_TRACE(fmt, ...) \
+ slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
+
+#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
+
+#endif /* _SLAPI_PLUGINS_UTIL_H */