mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added debug() and assert() functions
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@18 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
0f08471ad0
commit
084009d9ab
3 changed files with 23 additions and 18 deletions
12
Makefile
12
Makefile
|
@ -6,16 +6,14 @@ VPATH = src
|
|||
CC = gcc
|
||||
RM = rm -f
|
||||
|
||||
GIT_TAG = $(shell git describe --tags)
|
||||
GIT_TAG = $(shell git describe --tags --abbrev=0)
|
||||
GIT_REV = $(shell git rev-parse --short HEAD)
|
||||
|
||||
LDFLAGS = -pthread -lrt
|
||||
CFLAGS = -std=c99 -Iinclude/ -D_XOPEN_SOURCE=500
|
||||
CFLAGS += -D__GIT_REV__='"$(GIT_REV)"' -D__GIT_TAG__='"$(GIT_TAG)"'
|
||||
V ?= 0
|
||||
|
||||
ifdef (DEBUG)
|
||||
CFLAGS += -DDEBUG=$(DEBUG) -g
|
||||
endif
|
||||
LDFLAGS = -pthread -lrt
|
||||
CFLAGS = -g -std=c99 -Iinclude/ -D_XOPEN_SOURCE=500 -DV=$(V)
|
||||
CFLAGS += -D__GIT_REV__='"$(GIT_REV)"' -D__GIT_TAG__='"$(GIT_TAG)"'
|
||||
|
||||
.PHONY: all clean doc
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Some helper functions
|
||||
*
|
||||
* @author Steffen Vogel <steffen.vogel@rwth-aachen.de>
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
||||
*/
|
||||
|
||||
|
@ -26,6 +26,16 @@ enum log_level
|
|||
*/
|
||||
void print(enum log_level lvl, const char *fmt, ...);
|
||||
|
||||
#define assert(exp) do { \
|
||||
if (exp); print(FATAL, "Assertion failed: '%s' in %s, %s:%d", \
|
||||
#exp, __FUNCTION__, __BASE_FILE__, __LINE__); \
|
||||
} while(0)
|
||||
|
||||
#define debug(lvl, ...) do { \
|
||||
if (lvl <= V) \
|
||||
print(DEBUG, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Print short usage info to stdout
|
||||
*/
|
||||
|
|
17
src/server.c
17
src/server.c
|
@ -56,27 +56,24 @@ void quit()
|
|||
for (int i = 0; i < MAX_NODES && nodes[i]; i++)
|
||||
node_destroy(nodes[i]);
|
||||
|
||||
print(INFO, "Goodbye!");
|
||||
_exit(0);
|
||||
debug(1, "Goodbye!");
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
atexit(&quit);
|
||||
|
||||
assert(0);
|
||||
|
||||
if (argc != 1) {
|
||||
printf("Usage: s2ss [config]\n");
|
||||
printf("Usage: %s [config]\n", argv[0]);
|
||||
printf(" config is an optional path to a configuration file\n\n");
|
||||
printf("Simulator2Simulator Server %s\n", VERSION);
|
||||
printf(" Build: %s %s\n", __DATE__, __TIME__);
|
||||
printf(" Contact: Steffen Vogel <stvogel@eonerc.rwth-aachen.de\n");
|
||||
printf(" Copyright: 2014, Institute for Automation of Complex Power Systems, EONERC\n");
|
||||
printf("Simulator2Simulator Server %s (%s %s)\n", VERSION, __DATE__, __TIME__);
|
||||
printf(" Copyright 2014, Institute for Automation of Complex Power Systems, EONERC\n");
|
||||
printf(" Steffen Vogel <stvogel@eonerc.rwth-aachen.de>\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
print(INFO, "Good morning! This is s2ss %s", VERSION);
|
||||
debug(1, "Good morning! This is s2ss %s", VERSION);
|
||||
|
||||
init(); /* Setup paths and nodes manually */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue