Thread (89 messages) 89 messages, 4 authors, 2021-02-22

Re: [PATCH 06/35] monitor: Create a log() macro.

From: Martin Wilck <hidden>
Date: 2021-02-04 09:14:34

On Thu, 2021-02-04 at 08:01 +0100, Hannes Reinecke wrote:
On 1/26/21 9:32 PM, mwilck@suse.com wrote:
quoted
+               int __lvl =
(lvl);                                      \
+                                                                  
     \
+               if (__lvl <= MAX_LOGLEVEL && __lvl <= log_level)
{      \
+                       if (log_timestamp)
{                            \
+                               struct timespec
__ts;                   \
+                                                                  
     \
+                               clock_gettime(CLOCK_MONOTONIC,
&__ts);  \
+                               fprintf(stderr,                    
     \
+                                       _TIME_FMT _func_fmt
format,     \
+                                       __ts.tv_sec, __ts.tv_nsec /
1000,\
+                                       _func_arg,                 
     \
+                                       ##__VA_ARGS__);            
     \
+                       } else
{                                        \
+                               fprintf(stderr, _func_fmt
format,       \
+                                       _func_arg,                 
     \
+                                       ##__VA_ARGS__);            
     \
+                       };                                         
     \
+               }                                                  
     \
+       } while (0)
+
+#endif /* _LOG_H */
Urgh. Long macros are always horrible.
Can't you convert it into a function?
Sure. It won't work without macros, but I can write smaller ones.
It might also be an idea to move this as the first function, as it's
arguably an extension to existing functionality, and not directly 
related to the monitor.
Ok.

Thanks,
Martin



_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help