Commit 3f578b53 authored by Damien Lucas's avatar Damien Lucas

. Changed the compilation's output in the Makefile

. Added colors in logs when ERROR or FATAL logs happen
parent 49d3bf85
......@@ -8,6 +8,9 @@ CC = gcc
# Without the debugging version, LOGDEBUG has no effect.
CFLAGS += -DDEBUG
#Debug messages in color
CFLAGS += -DLINUX_COLOR
# Debug with the debugger
CFLAGS += -g
......@@ -77,43 +80,51 @@ LEXDEPS = $(LEXSOURCES:%.fl= deps/%.d)
LEXOBJECTS = $(LEXSOURCES:%.fl= %.o)
TARGET=VLANserver
########################### RULES DESCRIPTION #################################
all: dir dep VLANserver
all: dir dep $(TARGET)
dep: $(DEPS) $(LEXDEPS)
VLANserver: $(OBJECTS) $(LEXOBJECTS)
$(CC) -o $@ $(OBJECTS) $(LEXOBJECTS) $(LDFLAGS) $(CFLAGS) $(LDLIBS)
$(TARGET): $(OBJECTS) $(LEXOBJECTS)
@echo "Final linking"
@$(CC) -o $@ $(OBJECTS) $(LEXOBJECTS) $(CFLAGS) $(LDLIBS)
$(DEPS): deps/%.d: %.c
$(CC) $(CFLAGS) -MM $< | sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; [ -s$@ ] || rm -f $@
@echo "Generating dependancies for $*.c"
@$(CC) $(CFLAGS) $(DFLAGS) $< | sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; [ -s$@ ] || rm -f $@
$(OBJECTS): %.o: deps/%.d
@echo "Compiling $*.c"
@$(CC) $(CFLAGS) -c -o $@ $*.c
$(LEXDEPS): deps/%.d: %.c
$(CC) $(CFLAGS) -MM $< | sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; [ -s$@ ] || rm -f $@
@echo "Generating dependancies for $*.c"
@$(CC) $(CFLAGS) $(DFLAGS) $< | sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; [ -s$@ ] || rm -f $@
$(LEXOBJECTS): %.o: deps/%.d
@echo "Compiling $*.c"
@$(CC) $(CFLAGS) -c -o $@ $*.c
$(LEXCFILES): %.c: %.fl
$(LEX) $(LEXFLAGS) -o$@ $(@:%.c=%.fl)
dir:
mkdir -p deps
mkdir -p deps/config
mkdir -p deps/snmp
mkdir -p deps/db
mkdir -p deps/server
@echo "Running flex for generation of $*.fl"
@$(LEX) $(LEXFLAGS) -o$@ $<
dir:
@echo "Creating deps directory"
@mkdir -p deps
@mkdir -p deps/config
@mkdir -p deps/snmp
@mkdir -p deps/db
@mkdir -p deps/interface
@mkdir -p deps/server
clean:
rm -f $(OBJECTS)
rm -rf deps
rm -f $(LEXCFILES)
rm -f $(LEXOBJECTS)
rm -f $(LEXDEPS)
rm -f VLANserver
@echo "Removing deps direcrory, objects files, and VLANserver"
@rm -f $(OBJECTS)
@rm -rf deps
@rm -f $(LEXCFILES)
@rm -f $(LEXOBJECTS)
@rm -f VLANserver
......@@ -60,6 +60,15 @@ ERR_CODE VS_log(LOG_LEVELS level, LOG_MODULES module, char* format, ...)
case CFG:
sprintf(MsgBuff+strlen(MsgBuff), "[CFG : ");
break;
case IF:
sprintf(MsgBuff+strlen(MsgBuff), "[IF : ");
break;
case TELNET:
sprintf(MsgBuff+strlen(MsgBuff), "[TELNET: ");
break;
}
/* Determinate the error level */
......@@ -74,18 +83,40 @@ ERR_CODE VS_log(LOG_LEVELS level, LOG_MODULES module, char* format, ...)
case LOGWARNING:
sprintf(MsgBuff+strlen(MsgBuff), "Warning ] ");
break;
case LOGERROR:
sprintf(MsgBuff+strlen(MsgBuff), "ERROR ] ");
break;
case LOGFATAL:
sprintf(MsgBuff+strlen(MsgBuff), "FATAL ] ");
break;
{
#ifdef LINUX_COLOR
int i=strlen(MsgBuff);
MsgBuff[i]=27;
MsgBuff[i+1]='\0';
sprintf(MsgBuff+strlen(MsgBuff), "[40;31;1m");
#endif
sprintf(MsgBuff+strlen(MsgBuff), "FATAL ] ");
break;
}
case LOGERROR:
{
#ifdef LINUX_COLOR
int i=strlen(MsgBuff);
MsgBuff[i]=27;
MsgBuff[i+1]='\0';
sprintf(MsgBuff+strlen(MsgBuff), "[40;31;1m");
#endif
sprintf(MsgBuff+strlen(MsgBuff), "ERROR ] ");
break;
}
}
/* XXX No error checking ! What length is the message ? */
va_start(ap, format);
vsnprintf(MsgBuff+strlen(MsgBuff), LOGBUFF_MAXSIZE, format, ap);
sprintf(MsgBuff+strlen(MsgBuff), "\n");
{
int i=strlen(MsgBuff);
MsgBuff[i]=27;
MsgBuff[i+1]=0;
sprintf(MsgBuff+strlen(MsgBuff), "[0m\n");
}
va_end(ap);
printf("%s", MsgBuff);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment