[Spice-devel,spice-common] common/log.h: add spice_client_error

Submitted by Alon Levy on July 5, 2012, 9:38 a.m.

Details

Message ID 1341481096-14213-1-git-send-email-alevy@redhat.com
State Rejected
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy July 5, 2012, 9:38 a.m.
To be used to mark client protocol violations, more easily greppable.
---
 common/log.h |   11 +++++++++++
 1 file changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/common/log.h b/common/log.h
index 37c491f..df8a756 100644
--- a/common/log.h
+++ b/common/log.h
@@ -28,6 +28,10 @@  SPICE_BEGIN_DECLS
 #define SPICE_LOG_DOMAIN "Spice"
 #endif
 
+#ifndef SPICE_CLIENT_LOG_DOMAIN
+#define SPICE_CLIENT_LOG_DOMAIN "Spice(client)"
+#endif
+
 #define SPICE_STRINGIFY(x) SPICE_STRINGIFY_ARG (x)
 #define SPICE_STRINGIFY_ARG(x) #x
 
@@ -85,6 +89,13 @@  void spice_log(const char *log_domain,
 } SPICE_STMT_END
 #endif
 
+#ifndef spice_client_error
+#define spice_client_error(format, ...) SPICE_STMT_START {              \
+    spice_log(SPICE_CLIENT_LOG_DOMAIN,SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, \
+              __FUNCTION__, format, ## __VA_ARGS__);                    \
+} SPICE_STMT_END
+#endif
+
 #ifndef spice_debug
 #define spice_debug(format, ...) SPICE_STMT_START {                     \
     spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \

Comments

ACK.

On 07/05/2012 11:38 AM, Alon Levy wrote:
> To be used to mark client protocol violations, more easily greppable.
> ---
>   common/log.h |   11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/common/log.h b/common/log.h
> index 37c491f..df8a756 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -28,6 +28,10 @@ SPICE_BEGIN_DECLS
>   #define SPICE_LOG_DOMAIN "Spice"
>   #endif
>
> +#ifndef SPICE_CLIENT_LOG_DOMAIN
> +#define SPICE_CLIENT_LOG_DOMAIN "Spice(client)"
> +#endif
> +
>   #define SPICE_STRINGIFY(x) SPICE_STRINGIFY_ARG (x)
>   #define SPICE_STRINGIFY_ARG(x) #x
>
> @@ -85,6 +89,13 @@ void spice_log(const char *log_domain,
>   } SPICE_STMT_END
>   #endif
>
> +#ifndef spice_client_error
> +#define spice_client_error(format, ...) SPICE_STMT_START {              \
> +    spice_log(SPICE_CLIENT_LOG_DOMAIN,SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, \
> +              __FUNCTION__, format, ## __VA_ARGS__);                    \
> +} SPICE_STMT_END
> +#endif
> +
>   #ifndef spice_debug
>   #define spice_debug(format, ...) SPICE_STMT_START {                     \
>       spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>
On Thu, Jul 5, 2012 at 11:38 AM, Alon Levy <alevy@redhat.com> wrote:
> To be used to mark client protocol violations, more easily greppable.
> ---
>  common/log.h |   11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/common/log.h b/common/log.h
> index 37c491f..df8a756 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -28,6 +28,10 @@ SPICE_BEGIN_DECLS
>  #define SPICE_LOG_DOMAIN "Spice"
>  #endif
>
> +#ifndef SPICE_CLIENT_LOG_DOMAIN
> +#define SPICE_CLIENT_LOG_DOMAIN "Spice(client)"
> +#endif
> +
>  #define SPICE_STRINGIFY(x) SPICE_STRINGIFY_ARG (x)
>  #define SPICE_STRINGIFY_ARG(x) #x
>
> @@ -85,6 +89,13 @@ void spice_log(const char *log_domain,
>  } SPICE_STMT_END
>  #endif
>
> +#ifndef spice_client_error
> +#define spice_client_error(format, ...) SPICE_STMT_START {              \
> +    spice_log(SPICE_CLIENT_LOG_DOMAIN,SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, \
> +              __FUNCTION__, format, ## __VA_ARGS__);                    \
> +} SPICE_STMT_END
> +#endif
> +

Well, the idea is that you can define SPICE_LOG_DOMAIN before
including this file, either in your code, or in the Makefile, adding a
CFLAGS such as -DSPICE_LOG_DOMAIN=SpiceClient.

This way you don't need to introduce "domain specific" functions etc..

(just like  with glib logging)

cheers
On Thu, Jul 05, 2012 at 01:10:44PM +0200, Marc-André Lureau wrote:
> On Thu, Jul 5, 2012 at 11:38 AM, Alon Levy <alevy@redhat.com> wrote:
> > To be used to mark client protocol violations, more easily greppable.
> > ---
> >  common/log.h |   11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/common/log.h b/common/log.h
> > index 37c491f..df8a756 100644
> > --- a/common/log.h
> > +++ b/common/log.h
> > @@ -28,6 +28,10 @@ SPICE_BEGIN_DECLS
> >  #define SPICE_LOG_DOMAIN "Spice"
> >  #endif
> >
> > +#ifndef SPICE_CLIENT_LOG_DOMAIN
> > +#define SPICE_CLIENT_LOG_DOMAIN "Spice(client)"
> > +#endif
> > +
> >  #define SPICE_STRINGIFY(x) SPICE_STRINGIFY_ARG (x)
> >  #define SPICE_STRINGIFY_ARG(x) #x
> >
> > @@ -85,6 +89,13 @@ void spice_log(const char *log_domain,
> >  } SPICE_STMT_END
> >  #endif
> >
> > +#ifndef spice_client_error
> > +#define spice_client_error(format, ...) SPICE_STMT_START {              \
> > +    spice_log(SPICE_CLIENT_LOG_DOMAIN,SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, \
> > +              __FUNCTION__, format, ## __VA_ARGS__);                    \
> > +} SPICE_STMT_END
> > +#endif
> > +
> 
> Well, the idea is that you can define SPICE_LOG_DOMAIN before
> including this file, either in your code, or in the Makefile, adding a
> CFLAGS such as -DSPICE_LOG_DOMAIN=SpiceClient.
> 
> This way you don't need to introduce "domain specific" functions etc..
> 
> (just like  with glib logging)

That doesn't allow me to have in the same compilation unit (red_worker.c) two
domains. Also, you can't define macros with macros, so I'm not sure what
better way there is.

> 
> cheers
> -- 
> Marc-André Lureau
Hi

On Thu, Jul 5, 2012 at 1:17 PM, Alon Levy <alevy@redhat.com> wrote:
> That doesn't allow me to have in the same compilation unit (red_worker.c) two
> domains. Also, you can't define macros with macros, so I'm not sure what
> better way there is.

I'd put the macro in red_worker.c in this case.

And I wouldn't recommend a domain for that, but perhaps a common prefix.
On Thu, Jul 05, 2012 at 01:20:35PM +0200, Marc-André Lureau wrote:
> Hi
> 
> On Thu, Jul 5, 2012 at 1:17 PM, Alon Levy <alevy@redhat.com> wrote:
> > That doesn't allow me to have in the same compilation unit (red_worker.c) two
> > domains. Also, you can't define macros with macros, so I'm not sure what
> > better way there is.
> 
> I'd put the macro in red_worker.c in this case.
> 
> And I wouldn't recommend a domain for that, but perhaps a common prefix.

You dropped me from cc/to. OK - I'll send a v2 sometime (not urgent).

> 
> -- 
> Marc-André Lureau
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel