Re: [vdagent-win PATCH v4 17/19] vdlog: Avoids to having a lookup table for log types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patches 17-19 don't seem particularly compelling to me, but I guess I
don't mind. Unless anybody else objects:

Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>



On Mon, 2018-07-02 at 08:43 +0100, Frediano Ziglio wrote:
> As log type is passed as constant in some macros and the lockup
> is basically using this name without the prefix pass to the macro
> the name without the prefix.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  common/vdlog.h | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/common/vdlog.h b/common/vdlog.h
> index 9f08fc4..d017ac3 100644
> --- a/common/vdlog.h
> +++ b/common/vdlog.h
> @@ -59,8 +59,7 @@ static const VDLogLevel log_level = LOG_INFO;
>  #endif
>  
>  #define LOG(type, format, ...) do
> {                                     \
> -    if (type >= log_level && type <= LOG_FATAL)
> {                       \
> -        const char *type_as_char[] = { "DEBUG", "INFO", "WARN",
> "ERROR", "FATAL" }; \
> +    if (LOG_ ## type >= log_level && LOG_ ## type <= LOG_FATAL)
> {       \
>          struct _timeb
> now;                                              \
>          struct tm
> today;                                                \
>          char
> datetime_str[20];                                          \
> @@ -68,23 +67,23 @@ static const VDLogLevel log_level = LOG_INFO;
>          localtime_s(&today,
> &now.time);                                 \
>          strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S",
> &today);        \
>          VDLog::printf("%lu::%s::%s,%.3d::%s::" format
> "\n",             \
> -                      GetCurrentThreadId(),
> type_as_char[type],         \
> +                      GetCurrentThreadId(),
> #type,                      \
>                        datetime_str,
> now.millitm,                        \
>                        __FUNCTION__, ##
> __VA_ARGS__);                    \
>      }                                                               
>     \
>  } while(0)
>  
>  
> -#define vd_printf(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
> -#define LOG_INFO(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
> -#define LOG_WARN(format, ...) LOG(LOG_WARN, format, ## __VA_ARGS__)
> -#define LOG_ERROR(format, ...) LOG(LOG_ERROR, format, ##
> __VA_ARGS__)
> +#define vd_printf(format, ...) LOG(INFO, format, ## __VA_ARGS__)
> +#define LOG_INFO(format, ...) LOG(INFO, format, ## __VA_ARGS__)
> +#define LOG_WARN(format, ...) LOG(WARN, format, ## __VA_ARGS__)
> +#define LOG_ERROR(format, ...) LOG(ERROR, format, ## __VA_ARGS__)
>  
>  #define DBGLEVEL 1000
>  
>  #define DBG(level, format, ...) do {            \
>      if (level <= DBGLEVEL) {                    \
> -        LOG(LOG_DEBUG, format, ## __VA_ARGS__); \
> +        LOG(DEBUG, format, ## __VA_ARGS__);     \
>      }                                           \
>  } while(0)
>  
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]