Skip to content
Browse files

Every set should have a get...

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information...
1 parent 8c5c321 commit 59cb90efd32422fb7827f6f62bbe4efd949a9576 @fabbione committed Feb 1, 2013
Showing with 52 additions and 0 deletions.
  1. +18 −0 libknet/libknet.h
  2. +34 −0 libknet/logging.c
View
18 libknet/libknet.h
@@ -809,4 +809,22 @@ struct knet_log_msg {
int knet_log_set_loglevel(knet_handle_t knet_h, uint8_t subsystem,
uint8_t level);
+/*
+ * knet_log_get_log_level
+ *
+ * knet_h - same as above
+ *
+ * subsystem - same as above
+ *
+ * level - same as above
+ *
+ * knet_log_get_loglevel returns:
+ *
+ * 0 on success
+ * -1 on error and errno is set.
+ */
+
+int knet_log_get_loglevel(knet_handle_t knet_h, uint8_t subsystem,
+ uint8_t *level);
+
#endif
View
34 libknet/logging.c
@@ -130,6 +130,40 @@ int knet_log_set_loglevel(knet_handle_t knet_h, uint8_t subsystem,
return 0;
}
+int knet_log_get_loglevel(knet_handle_t knet_h, uint8_t subsystem,
+ uint8_t *level)
+{
+ int savederrno = 0;
+
+ if (!knet_h) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (subsystem > KNET_SUB_LAST) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (!level) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ savederrno = pthread_rwlock_rdlock(&knet_h->list_rwlock);
+ if (savederrno) {
+ log_err(knet_h, subsystem, "Unable to get write lock: %s",
+ strerror(savederrno));
+ errno = savederrno;
+ return -1;
+ }
+
+ *level = knet_h->log_levels[subsystem];
+
+ pthread_rwlock_unlock(&knet_h->list_rwlock);
+ return 0;
+}
+
void log_msg(knet_handle_t knet_h, uint8_t subsystem, uint8_t msglevel,
const char *fmt, ...)
{

0 comments on commit 59cb90e

Please sign in to comment.
Something went wrong with that request. Please try again.