aboutsummaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@opmbx.org>2015-04-26 21:43:42 -0300
committerMatias Linares <matiaslina@opmbx.org>2015-04-26 21:43:42 -0300
commit2dd5cf430edaae01594d566c9f27d780c3ffb4ef (patch)
tree13111bc82a73e951d5d7c07865a206c025d15529 /log.c
downloadmedianinfs-2dd5cf430edaae01594d566c9f27d780c3ffb4ef.tar.gz
Initial commit
Diffstat (limited to 'log.c')
-rw-r--r--log.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/log.c b/log.c
new file mode 100644
index 0000000..cfa1cf6
--- /dev/null
+++ b/log.c
@@ -0,0 +1,50 @@
+/* $Date: 2010-09-30 15:40:39 -0300 (Thu, 30 Sep 2010) $ */
+/* $Revision: 1364 $ */
+
+#include "log.h"
+#include <stdarg.h>
+
+static int loglevel=0;
+static FILE *logfile=NULL;
+
+int log_open(const char *filename, const int ll)
+{
+ loglevel = 0;
+ if (filename == NULL) logfile = stdout;
+ else logfile = fopen(filename, "w");
+ if (logfile == NULL) return 1;
+ loglevel = ll;
+ return 0;
+}
+
+void log_close(void)
+{
+ fclose(logfile);
+}
+
+void debug1(const char * format, ...)
+{
+ va_list args;
+ if (loglevel < 1 || logfile == NULL) return;
+ va_start(args, format);
+ vfprintf(logfile,format,args);
+ va_end(args);
+}
+
+void debug2(const char *format, ...)
+{
+ va_list args;
+ if (loglevel < 2 || logfile == NULL) return;
+ va_start(args, format);
+ vfprintf(logfile,format,args);
+ va_end(args);
+}
+
+void debug3(const char *format, ...)
+{
+ va_list args;
+ if (loglevel < 3 || logfile == NULL) return;
+ va_start(args, format);
+ vfprintf(logfile,format,args);
+ va_end(args);
+}