summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile20
-rw-r--r--main_complete.c (renamed from main.c)25
-rw-r--r--main_filter.c58
-rw-r--r--main_mutex.c57
-rw-r--r--main_simple.c67
-rw-r--r--main_syslog.c57
6 files changed, 268 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 89cf611..776ea60 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,20 @@
include Makefile.files
-all:
- g++ -Werror -Wall -D_FORTIFY_SOURCE=2 -g -O2 ${DEBUG_SOURCES} main.c -o debug -DWITH_DBG_SYSLOG -DWITH_DEBUG
+CFLAGS=-Werror -Wall -D_FORTIFY_SOURCE=2 -g -O2
+
+all: complete simple syslog filter mutex
+
+complete:
+ g++ ${CFLAGS} ${DEBUG_SOURCES} main_complete.c -o debug-complete -DWITH_DBG_SYSLOG -DWITH_DBG_FILTER -DWITH_DBG_MUTEX
+
+simple:
+ g++ ${CFLAGS} debug.c main_simple.c -o debug-simple
+
+syslog:
+ g++ ${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
+
+mutex:
+ g++ ${CFLAGS} debug.c main_mutex.c -o debug-mutex -DWITH_DBG_MUTEX
diff --git a/main.c b/main_complete.c
index 00a637f..74a31e9 100644
--- a/main.c
+++ b/main_complete.c
@@ -35,27 +35,24 @@
int main(int argc, char *argv[])
{
- /*
int fd = open("/tmp/my.log", O_CREAT | O_RDWR, 0777);
if(fd == -1) {
return 1;
}
- */
- dbg_status_t status = dbg_init(//DBG_FLAG_USE_MUTEX |
- //DBG_FLAG_OUTPUT_TO_FILE |
+ dbg_status_t status = dbg_init(DBG_FLAG_USE_MUTEX |
+ DBG_FLAG_OUTPUT_TO_FILE |
DBG_FLAG_OUTPUT_TO_FD |
-// DBG_FLAG_OUTPUT_TO_STDOUT |
+ DBG_FLAG_OUTPUT_TO_STDOUT |
DBG_FLAG_OUTPUT_TO_SYSLOG |
- //DBG_FLAG_OUTPUT_TO_STDERR |
-// DBG_FLAG_USE_FILTER |
+ DBG_FLAG_OUTPUT_TO_STDERR |
+ DBG_FLAG_USE_FILTER |
0,
- //DBG_OPTION_FD, fd,
-// DBG_OPTION_FILENAME, "",
- DBG_OPTION_SYSLOG_HOST,
- "127.0.0.1",
- DBG_OPTION_SYSLOG_PORT,
- 514,
-// DBG_OPTION_FILTER, "+all",
+ DBG_OPTION_FD, fd,
+ DBG_OPTION_FILENAME, "/tmp/my2.log",
+ DBG_OPTION_STDOUT_NO_DATE, 1,
+ DBG_OPTION_SYSLOG_HOST, "127.0.0.1",
+ DBG_OPTION_SYSLOG_PORT, 514,
+ DBG_OPTION_FILTER, "+all",
DBG_OPTION_END);
if(status != DBG_STATUS_OK) {
diff --git a/main_filter.c b/main_filter.c
new file mode 100644
index 0000000..83e500b
--- /dev/null
+++ b/main_filter.c
@@ -0,0 +1,58 @@
+/* -*- 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"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ dbg_status_t status = dbg_init(DBG_FLAG_OUTPUT_TO_STDOUT |
+ DBG_FLAG_USE_FILTER |
+ 0,
+ DBG_OPTION_FILTER, "-all,+example",
+ DBG_OPTION_END);
+
+ if(status != DBG_STATUS_OK) {
+ printf("Error: %d\n", status);
+ return 1;
+ }
+
+ INFO(example, "We are up and running");
+
+ DEBUG(example, "Or are we %d?", 42);
+
+ DEBUG(foo, "Or are we %d?", 42);
+
+ dbg_close();
+
+ return 0;
+}
diff --git a/main_mutex.c b/main_mutex.c
new file mode 100644
index 0000000..7370832
--- /dev/null
+++ b/main_mutex.c
@@ -0,0 +1,57 @@
+/* -*- 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"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ dbg_status_t status = dbg_init(DBG_FLAG_USE_MUTEX |
+ DBG_FLAG_OUTPUT_TO_STDOUT |
+ 0,
+ DBG_OPTION_END);
+
+ if(status != DBG_STATUS_OK) {
+ printf("Error: %d\n", status);
+ return 1;
+ }
+
+ INFO(example, "We are up and running");
+
+ DEBUG(example, "Or are we %d?", 42);
+
+ DEBUG(foo, "Or are we %d?", 42);
+
+ dbg_close();
+
+ return 0;
+}
diff --git a/main_simple.c b/main_simple.c
new file mode 100644
index 0000000..220f102
--- /dev/null
+++ b/main_simple.c
@@ -0,0 +1,67 @@
+/* -*- 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"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int fd = open("/tmp/my.log", O_CREAT | O_RDWR, 0777);
+ if(fd == -1) {
+ return 1;
+ }
+
+ dbg_status_t status = dbg_init(DBG_FLAG_OUTPUT_TO_FILE |
+ DBG_FLAG_OUTPUT_TO_FD |
+ DBG_FLAG_OUTPUT_TO_STDOUT |
+ DBG_FLAG_OUTPUT_TO_STDERR |
+ 0,
+ DBG_OPTION_FD, fd,
+ DBG_OPTION_FILENAME, "/tmp/my2.log",
+ DBG_OPTION_STDOUT_NO_DATE, 0,
+ DBG_OPTION_END);
+
+ if(status != DBG_STATUS_OK) {
+ printf("Error: %d\n", status);
+ return 1;
+ }
+
+ INFO(example, "We are up and running");
+
+ DEBUG(example, "Or are we %d?", 42);
+
+ DEBUG(foo, "Or are we %d?", 42);
+
+ dbg_close();
+
+ return 0;
+}
diff --git a/main_syslog.c b/main_syslog.c
new file mode 100644
index 0000000..123f8ed
--- /dev/null
+++ b/main_syslog.c
@@ -0,0 +1,57 @@
+/* -*- 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"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ dbg_status_t status = dbg_init(DBG_FLAG_OUTPUT_TO_SYSLOG,
+ DBG_OPTION_SYSLOG_HOST, "127.0.0.1",
+ DBG_OPTION_SYSLOG_PORT, 514,
+ DBG_OPTION_END);
+
+ if(status != DBG_STATUS_OK) {
+ printf("Error: %d\n", status);
+ return 1;
+ }
+
+ INFO(example, "We are up and running");
+
+ DEBUG(example, "Or are we %d?", 42);
+
+ DEBUG(foo, "Or are we %d?", 42);
+
+ dbg_close();
+
+ return 0;
+}