Re: [Freeipa-devel] [PATCH 0041] Cleanup in logging code

2012-07-26 Thread Petr Spacek

On 07/26/2012 10:06 AM, Adam Tkac wrote:

On Wed, Jul 25, 2012 at 03:31:34PM +0200, Petr Spacek wrote:

Hello,

this patch clears logging code a bit. Adding functions like
log_info() and similar will be trivial from now.

It will be necessary for ticket #71: Log successful reconnect
https://fedorahosted.org/bind-dyndb-ldap/ticket/71


Ack.



Pushed to the master:

http://git.fedorahosted.org/git?p=bind-dyndb-ldap.git;a=commitdiff;h=b04dfcbe328a8e713597921f7a43c9c8dd801e63

Petr^2 Spacek

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 0041] Cleanup in logging code

2012-07-26 Thread Adam Tkac
On Wed, Jul 25, 2012 at 03:31:34PM +0200, Petr Spacek wrote:
> Hello,
> 
> this patch clears logging code a bit. Adding functions like
> log_info() and similar will be trivial from now.
> 
> It will be necessary for ticket #71: Log successful reconnect
> https://fedorahosted.org/bind-dyndb-ldap/ticket/71

Ack.

> From 26136d6fe5fce5ac4f3138063bcf4774f268bd3c Mon Sep 17 00:00:00 2001
> From: Petr Spacek 
> Date: Thu, 19 Jul 2012 14:13:12 +0200
> Subject: [PATCH] Cleanup in logging code.
> 
> Signed-off-by: Petr Spacek 
> ---
>  src/log.c |   22 ++
>  src/log.h |   19 ---
>  2 files changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/src/log.c b/src/log.c
> index 
> b23e4720a8dd484a65d8a7e6c58baf257fc9ce50..f731df706b58e1f894659811dae32d4148a8620c
>  100644
> --- a/src/log.c
> +++ b/src/log.c
> @@ -28,31 +28,13 @@
>  #include "log.h"
>  
>  void
> -log_debug(int level, const char *format, ...)
> +log_write(int level, const char *format, ...)
>  {
>   va_list args;
>  
>   va_start(args, format);
> -#ifdef LOG_AS_ERROR
> - UNUSED(level);
>   isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
> -ISC_LOG_ERROR, format, args);
> -#else
> - isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
> -ISC_LOG_DEBUG(level), format, args);
> -#endif
> -
> - va_end(args);
> -}
> -
> -void
> -log_error(const char *format, ...)
> -{
> - va_list args;
> -
> - va_start(args, format);
> - isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
> -ISC_LOG_ERROR, format, args);
> +level, format, args);
>   va_end(args);
>  
>  }
> diff --git a/src/log.h b/src/log.h
> index 
> 0df4e25618fab932bdec97c276580d1b9d31bf08..898639be144dbf6049a1440493c3358e01a5c2dd
>  100644
> --- a/src/log.h
> +++ b/src/log.h
> @@ -22,18 +22,31 @@
>  #define _LD_LOG_H_
>  
>  #include 
> +#include 
> +
> +#ifdef LOG_AS_ERROR
> +#define GET_LOG_LEVEL(level) ISC_LOG_ERROR
> +#else
> +#define GET_LOG_LEVEL(level) (level)
> +#endif
>  
>  #define fatal_error(...) \
>  isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__)
>  
>  #define log_bug(fmt, ...) \
>   log_error("bug in %s(): " fmt, __func__,##__VA_ARGS__)
>  
>  #define log_error_r(fmt, ...) \
> - log_error(fmt ": %s", ##__VA_ARGS__, isc_result_totext(result))
> + log_error(fmt ": %s", ##__VA_ARGS__, dns_result_totext(result))
>  
>  /* Basic logging functions */
> -void log_debug(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
> -void log_error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
> +#define log_error(format, ...)   \
> + log_write(GET_LOG_LEVEL(ISC_LOG_ERROR), format, ##__VA_ARGS__)
> +
> +#define log_debug(level, format, ...)\
> + log_write(GET_LOG_LEVEL(level), format, ##__VA_ARGS__)
> +
> +void
> +log_write(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
>  
>  #endif /* !_LD_LOG_H_ */
> -- 
> 1.7.10.4
> 


-- 
Adam Tkac, Red Hat, Inc.

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH 0041] Cleanup in logging code

2012-07-25 Thread Petr Spacek

Hello,

this patch clears logging code a bit. Adding functions like log_info() and 
similar will be trivial from now.


It will be necessary for ticket #71: Log successful reconnect
https://fedorahosted.org/bind-dyndb-ldap/ticket/71

Petr^2 Spacek
From 26136d6fe5fce5ac4f3138063bcf4774f268bd3c Mon Sep 17 00:00:00 2001
From: Petr Spacek 
Date: Thu, 19 Jul 2012 14:13:12 +0200
Subject: [PATCH] Cleanup in logging code.

Signed-off-by: Petr Spacek 
---
 src/log.c |   22 ++
 src/log.h |   19 ---
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/log.c b/src/log.c
index b23e4720a8dd484a65d8a7e6c58baf257fc9ce50..f731df706b58e1f894659811dae32d4148a8620c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -28,31 +28,13 @@
 #include "log.h"
 
 void
-log_debug(int level, const char *format, ...)
+log_write(int level, const char *format, ...)
 {
 	va_list args;
 
 	va_start(args, format);
-#ifdef LOG_AS_ERROR
-	UNUSED(level);
 	isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
-		   ISC_LOG_ERROR, format, args);
-#else
-	isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
-		   ISC_LOG_DEBUG(level), format, args);
-#endif
-
-	va_end(args);
-}
-
-void
-log_error(const char *format, ...)
-{
-	va_list args;
-
-	va_start(args, format);
-	isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
-		   ISC_LOG_ERROR, format, args);
+		   level, format, args);
 	va_end(args);
 
 }
diff --git a/src/log.h b/src/log.h
index 0df4e25618fab932bdec97c276580d1b9d31bf08..898639be144dbf6049a1440493c3358e01a5c2dd 100644
--- a/src/log.h
+++ b/src/log.h
@@ -22,18 +22,31 @@
 #define _LD_LOG_H_
 
 #include 
+#include 
+
+#ifdef LOG_AS_ERROR
+#define GET_LOG_LEVEL(level)	ISC_LOG_ERROR
+#else
+#define GET_LOG_LEVEL(level)	(level)
+#endif
 
 #define fatal_error(...) \
 isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__)
 
 #define log_bug(fmt, ...) \
 	log_error("bug in %s(): " fmt, __func__,##__VA_ARGS__)
 
 #define log_error_r(fmt, ...) \
-	log_error(fmt ": %s", ##__VA_ARGS__, isc_result_totext(result))
+	log_error(fmt ": %s", ##__VA_ARGS__, dns_result_totext(result))
 
 /* Basic logging functions */
-void log_debug(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
-void log_error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
+#define log_error(format, ...)	\
+	log_write(GET_LOG_LEVEL(ISC_LOG_ERROR), format, ##__VA_ARGS__)
+
+#define log_debug(level, format, ...)	\
+	log_write(GET_LOG_LEVEL(level), format, ##__VA_ARGS__)
+
+void
+log_write(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
 
 #endif /* !_LD_LOG_H_ */
-- 
1.7.10.4

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel