Some missing ifndef-tags for no_loging fixed

Added nolog compile-option to Makefile


git-svn-id: file:///home/jan/tmp/wetterstation/trunk@10 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi 2006-08-13 00:38:57 +00:00
parent 3427ef07ec
commit 2da73b3073
5 changed files with 28 additions and 10 deletions

View File

@ -16,26 +16,32 @@ all: $(BIN_NAME)
$(BIN_NAME): main.o config.o input.o process.o write.o
$(LD) $(DEBUG) -L/usr/lib/pgsql -lpq $(LDFLAS) $(BIN_NAME) main.o input.o process.o write.o config.o
$(LD) $(DEBUG) $(NOLOG) -L/usr/lib/pgsql -lpq $(LDFLAS) $(BIN_NAME) main.o input.o process.o write.o config.o
main.o: main.c main.h definitions.h config.h input.h
$(CC) $(DEBUG) -c main.c
$(CC) $(DEBUG) $(NOLOG) $(CFLAGS) main.c
config.o: config.c config.h definitions.h
$(CC) $(DEBUG) -c config.c
$(CC) $(DEBUG) $(NOLOG) $(CFLAGS) config.c
input.o: input.c input.h main.h config.h definitions.h process.h
$(CC) $(DEBUG) -c input.c
$(CC) $(DEBUG) $(NOLOG) $(CFLAGS) input.c
process.o: process.c process.h main.h config.h definitions.h write.h
$(CC) $(DEBUG) -c process.c
$(CC) $(DEBUG) $(NOLOG) $(CFLAGS) process.c
write.o: write.c write.h main.h definitions.h
$(CC) $(DEBUG) -I/usr/include/postgresql -o write.o -c write.c
$(CC) $(DEBUG) $(NOLOG) -I/usr/include/postgresql $(CFLAGS) write.c
# Programm mit debug-ausgabe bauen
debug:
$(MAKE) all DEBUG=-DDEBUG
# Programm ohne Log-ausgabe bauen
nolog:
$(MAKE) all NOLOG=-DNO_LOGING
# Aufräumnen (alle Object-Files löschen)
cleanup:
echo "Räume auf...entferne:"
echo " " *.o

View File

@ -47,10 +47,12 @@ static int flag_handler(int *, int , const char *);
static const struct config_keyword keywords[] = {
/* keyword handler variable address default */
{"interface", read_str, &(global_opts.device), DEFAULT_SERIAL_PORT},
#ifndef NO_LOGING
{"log_data", read_log_data_flag, &(global_opts.flags), "no"},
{"log_error", read_log_error_flag, &(global_opts.flags), "no"},
{"data_file", read_str, &(global_opts.data_log), DEFAULT_DATA_FILE},
{"error_file", read_str, &(global_opts.error_log), DEFAULT_ERROR_FILE},
#endif
{"foreground", read_foreground_flag, &(global_opts.flags), "no"},
{"verbose", read_verbose_flag, &(global_opts.flags), "no"},
{"pg_host", read_str, &(global_opts.pg_host), DEFAULT_PG_HOST},
@ -74,6 +76,7 @@ static int read_str(const char *line, void *arg){
/* Die 4 Funktionen reichen jeweils nur die Daten an den
* flag_handler durch und teilen diesem noch das Flag
* mit, was er setzen soll (oder nicht) */
#ifndef NO_LOGING
static read_log_data_flag(const char *line, void *arg){
return flag_handler(arg, LOG_DATA_FLAG, line);
}
@ -81,6 +84,7 @@ static read_log_data_flag(const char *line, void *arg){
static read_log_error_flag(const char *line, void *arg){
return flag_handler(arg, LOG_ERROR_FLAG, line);
}
#endif
static read_foreground_flag(const char *line, void *arg){
return flag_handler(arg, FOREGROUND_FLAG, line);

View File

@ -60,10 +60,12 @@
/* Parameter-Flags ----------------------------------------------------- */
#define LOG_ERROR_FLAG 0x01
#define LOG_DATA_FLAG 0x02
#define FOREGROUND_FLAG 0x04
#define VERBOSE_FLAG 0x08
#define FOREGROUND_FLAG 0x01
#define VERBOSE_FLAG 0x02
#ifndef NO_LOGING
#define LOG_ERROR_FLAG 0x04
#define LOG_DATA_FLAG 0x08
#endif
/* Puffergrößen -------------------------------------------------------- */

View File

@ -163,10 +163,12 @@ static void background(){
static void merge_options(w_opts *priv){
if((*priv).device != NULL)
global_opts.device = (*priv).device;
#ifndef NO_LOGING
if((*priv).data_log != NULL)
global_opts.data_log = (*priv).data_log;
if((*priv).error_log != NULL)
global_opts.error_log = (*priv).error_log;
#endif
global_opts.flags |= (*priv).flags;
}

View File

@ -126,8 +126,10 @@ static int pg_connect(){
}
if(PQstatus(connection) != CONNECTION_OK){
DEBUGOUT2("\nFehler beim Aufbau der Datenbankverbindung\n%s\n", PQerrorMessage(connection));
#ifndef NO_LOGING
snprintf(get_error_buffer(), ERR_BUFFERSIZE, "Fehler beim Aufbau der Datenbankverbindung: %s", PQerrorMessage(connection));
log_error(get_error_buffer());
#endif
return 0;
}
DEBUGOUT1("\nDatenbankverbindung erfolgreich hergestellt\n");
@ -141,8 +143,10 @@ static void pg_insert(char *query){
res = PQexec(connection, query);
if(!res || PQresultStatus(res) != PGRES_COMMAND_OK){
DEBUGOUT2("Fehler beim INSERT: %s\n", query);
#ifndef NO_LOGING
snprintf(get_error_buffer(), ERR_BUFFERSIZE, "Fehler beim INSERT: %s", query);
log_error(get_error_buffer());
#endif
} else {
DEBUGOUT2("Query: '%s' ausgeführt\n", query);
}