ref: 38d4b2728285793eadee9681aa33c2af9e9d85dd
parent: 14ea0588290380eb09b2c8e29e6a3315cb7bfb64
author: qwx <qwx@sciops.net>
date: Wed Mar 30 01:42:24 EDT 2022
add small debug print wrapper
--- a/asif.h
+++ b/asif.h
@@ -91,3 +91,13 @@
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
#define SQRT2 1.4142135623730951
+
+enum{
+ Lognone,
+ Logdebug,
+ Logtrace,
+};
+extern int debuglevel;
+
+void dprint(char *, ...);
+#pragma varargck argpos dprint 1
--- /dev/null
+++ b/dprint.c
@@ -1,0 +1,19 @@
+#include <u.h>
+#include <libc.h>
+#include "asif.h"
+
+int debuglevel;
+
+void
+dprint(char *fmt, ...)
+{
+ char s[256];
+ va_list arg;
+
+ if(debuglevel == Lognone)
+ return;
+ va_start(arg, fmt);
+ vseprint(s, s+sizeof s, fmt, arg);
+ va_end(arg);
+ fprint(2, "%s", s);
+}