diff options
author | Geoff Levand <geoff@infradead.org> | 2018-08-02 17:29:33 +0000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2018-08-07 11:30:36 +1000 |
commit | 679d9dceb5bdf51f118548ca2645dc81088a8974 (patch) | |
tree | 40ccf5ccffa7f6dd1dd4bfec134613f178b8bdab /lib/log/log.c | |
parent | e2185d2c52325bd6695f79eff38dfab63cb0d49c (diff) | |
download | talos-petitboot-679d9dceb5bdf51f118548ca2645dc81088a8974.tar.gz talos-petitboot-679d9dceb5bdf51f118548ca2645dc81088a8974.zip |
lib/log: Add verbose logging routines
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>
Diffstat (limited to 'lib/log/log.c')
-rw-r--r-- | lib/log/log.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/log/log.c b/lib/log/log.c index adb2078..0b145e0 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -34,6 +34,15 @@ void pb_log(const char *fmt, ...) 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; @@ -44,6 +53,28 @@ void pb_debug(const char *fmt, ...) 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) |