From 1c9de14fb39305fb643d50acde6c389330d07ac2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 13 Dec 2012 11:01:43 +0100 Subject: Make several build targets. --- Makefile | 20 +++++++++++++-- main.c | 75 --------------------------------------------------------- main_complete.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ main_filter.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ main_mutex.c | 57 +++++++++++++++++++++++++++++++++++++++++++ main_simple.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ main_syslog.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 329 insertions(+), 77 deletions(-) delete mode 100644 main.c create mode 100644 main_complete.c create mode 100644 main_filter.c create mode 100644 main_mutex.c create mode 100644 main_simple.c create mode 100644 main_syslog.c diff --git a/Makefile b/Makefile index 89cf611..e632edb 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_simple.c -o debug-mutex -DWITH_DBG_MUTEX diff --git a/main.c b/main.c deleted file mode 100644 index 00a637f..0000000 --- a/main.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- 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 -#include -#include - -#include - -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_FLAG_OUTPUT_TO_FD | -// DBG_FLAG_OUTPUT_TO_STDOUT | - DBG_FLAG_OUTPUT_TO_SYSLOG | - //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_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_complete.c b/main_complete.c new file mode 100644 index 0000000..74a31e9 --- /dev/null +++ b/main_complete.c @@ -0,0 +1,72 @@ +/* -*- 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 +#include +#include + +#include + +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_FLAG_OUTPUT_TO_FD | + DBG_FLAG_OUTPUT_TO_STDOUT | + DBG_FLAG_OUTPUT_TO_SYSLOG | + DBG_FLAG_OUTPUT_TO_STDERR | + DBG_FLAG_USE_FILTER | + 0, + 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) { + 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_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 +#include +#include + +#include + +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 +#include +#include + +#include + +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 +#include +#include + +#include + +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 +#include +#include + +#include + +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; +} -- cgit v1.2.3