summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--debug.c32
-rw-r--r--main_minimal.c39
3 files changed, 76 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 776ea60..c397c53 100644
--- a/Makefile
+++ b/Makefile
@@ -2,19 +2,28 @@ include Makefile.files
CFLAGS=-Werror -Wall -D_FORTIFY_SOURCE=2 -g -O2
-all: complete simple syslog filter mutex
+all: complete complete-cpp simple syslog filter mutex minimal
complete:
- g++ ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX
+ gcc ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX
+
+complete-cpp:
+ g++ ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete-cpp -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX
simple:
- g++ ${CFLAGS} debug.c main_simple.c -o debug-simple
+ gcc ${CFLAGS} debug.c main_simple.c -o debug-simple
+
+minimal:
+ gcc ${CFLAGS} debug.c main_minimal.c -o debug-minimal
syslog:
- g++ ${CFLAGS} debug.c debug_syslog.c main_syslog.c -o debug-syslog -DWITH_DBG_SYSLOG
+ gcc ${CFLAGS} debug.c debug_syslog.c main_syslog.c -o debug-syslog -DWITH_DBG_SYSLOG
filter:
- g++ ${CFLAGS} debug.c debug_filter.c main_filter.c -o debug-filter -DWITH_DBG_FILTER
+ gcc ${CFLAGS} debug.c debug_filter.c main_filter.c -o debug-filter -DWITH_DBG_FILTER
mutex:
- g++ ${CFLAGS} debug.c main_mutex.c -o debug-mutex -DWITH_DBG_MUTEX
+ gcc ${CFLAGS} debug.c main_mutex.c -o debug-mutex -DWITH_DBG_MUTEX
+
+clean:
+ rm -f debug_{complete,complete-cpp,simple,syslog,filter,mutex,minimal} \ No newline at end of file
diff --git a/debug.c b/debug.c
index 8b48204..5c04b61 100644
--- a/debug.c
+++ b/debug.c
@@ -51,18 +51,35 @@
struct dbg_config_t {
unsigned int flags;
-#ifdef WITH_DBG_MUTEX
- pthread_mutex_t mutex;
-#endif
int fd;
int file_fd;
int stdout_no_date;
+#ifdef WITH_DBG_MUTEX
+ pthread_mutex_t mutex;
+#endif
#ifdef WITH_DBG_SYSLOG
const char* syslog_host;
int syslog_port;
#endif
-};// dbg_config;// = { .flags = DBG_FLAG_DEFAULT, .fd = -1, .file_fd = -1 };
-static struct dbg_config_t dbg_config;
+} dbg_config = {
+ DBG_FLAG_DEFAULT, // flags
+ -1, // fd
+ -1, // file_fd
+ 0, //stdout_no_date
+#ifdef WITH_DBG_MUTEX
+ {}, // mutex;
+#endif
+#ifdef WITH_DBG_SYSLOG
+ "", // syslog_host;
+ -1, // syslog_port;
+#endif
+ /* // This doesn't work in C++
+ .flags = DBG_FLAG_DEFAULT,
+ .fd = -1,
+ .file_fd = -1,
+ .stdout_no_date = 0
+ */
+};
static void dbg_mutex_init()
{
@@ -109,10 +126,6 @@ dbg_status_t dbg_init(unsigned int flags, ...)
dbg_config.flags = flags;
- dbg_config.fd = -1;
- dbg_config.file_fd = -1;
- dbg_config.stdout_no_date = 0;
-
int end = 0;
va_list vl;
@@ -289,4 +302,3 @@ done:
return result;
}
-
diff --git a/main_minimal.c b/main_minimal.c
new file mode 100644
index 0000000..63887ef
--- /dev/null
+++ b/main_minimal.c
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * main.cc
+ *
+ * Fri Dec 7 09:35:45 CET 2012
+ * Copyright 2012 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Debug Module.
+ *
+ * Debug Module is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Debug Module is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Debug Module; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "debug.h"
+
+int main(int argc, char *argv[])
+{
+ INFO(example, "We are up and running");
+
+ DEBUG(example, "Or are we %d?", 42);
+
+ DEBUG(foo, "Or are we %d?", 42);
+
+ return 0;
+}