]> git.ozlabs.org Git - petitboot/commitdiff
lib/log: Add verbose logging routines
authorGeoff Levand <geoff@infradead.org>
Thu, 2 Aug 2018 17:29:33 +0000 (17:29 +0000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 7 Aug 2018 01:30:36 +0000 (11:30 +1000)
Add three new logging routines pb_log_fn and pb_debug_fn, which
print the calling function's name to the log, and pb_debug_fl
which prints the calling function's name and the file line
number to the log.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
lib/log/log.c
lib/log/log.h
s [new file with mode: 0644]

index adb207862b1c4a65286f6bb63aaf2b70ed76f99c..0b145e0d3d6013f608935b3b696c3863e887c2a1 100644 (file)
@@ -34,6 +34,15 @@ void pb_log(const char *fmt, ...)
        va_end(ap);
 }
 
        va_end(ap);
 }
 
+void _pb_log_fn(const char *func, const char *fmt, ...)
+{
+       va_list ap;
+       pb_log("%s: ", func);
+       va_start(ap, fmt);
+       __log(fmt, ap);
+       va_end(ap);
+}
+
 void pb_debug(const char *fmt, ...)
 {
        va_list ap;
 void pb_debug(const char *fmt, ...)
 {
        va_list ap;
@@ -44,6 +53,28 @@ void pb_debug(const char *fmt, ...)
        va_end(ap);
 }
 
        va_end(ap);
 }
 
+void _pb_debug_fn(const char *func, const char *fmt, ...)
+{
+       va_list ap;
+       if (!debug)
+               return;
+       pb_log("%s: ", func);
+       va_start(ap, fmt);
+       __log(fmt, ap);
+       va_end(ap);
+}
+
+void _pb_debug_fl(const char *func, int line, const char *fmt, ...)
+{
+       va_list ap;
+       if (!debug)
+               return;
+       pb_log("%s:%d: ", func, line);
+       va_start(ap, fmt);
+       __log(fmt, ap);
+       va_end(ap);
+}
+
 void __pb_log_init(FILE *fp, bool _debug)
 {
        if (logf)
 void __pb_log_init(FILE *fp, bool _debug)
 {
        if (logf)
index 94545960f59690f0c087849a2c87b411f0249ccf..2d4fd915f9716d81a6b3836d6c822cfae7d082ed 100644 (file)
@@ -5,7 +5,17 @@
 #include <stdio.h>
 
 void __attribute__ ((format (printf, 1, 2))) pb_log(const char *fmt, ...);
 #include <stdio.h>
 
 void __attribute__ ((format (printf, 1, 2))) pb_log(const char *fmt, ...);
+void __attribute__ ((format (printf, 2, 3))) _pb_log_fn(const char *func,
+       const char *fmt, ...);
+#define pb_log_fn(args...) _pb_log_fn(__func__, args)
+
 void __attribute__ ((format (printf, 1, 2))) pb_debug(const char *fmt, ...);
 void __attribute__ ((format (printf, 1, 2))) pb_debug(const char *fmt, ...);
+void __attribute__ ((format (printf, 2, 3))) _pb_debug_fn(const char *func,
+       const char *fmt, ...);
+#define pb_debug_fn(args...) _pb_debug_fn(__func__, args)
+void __attribute__ ((format (printf, 3, 4))) _pb_debug_fl(const char *func,
+       int line, const char *fmt, ...);
+#define pb_debug_fl(args...) _pb_debug_fl(__func__, __LINE__, args)
 
 void __pb_log_init(FILE *stream, bool debug);
 
 
 void __pb_log_init(FILE *stream, bool debug);
 
diff --git a/s b/s
new file mode 100644 (file)
index 0000000..e69de29