example test
This commit is contained in:
parent
223a2e6db7
commit
5fd9f4fef9
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
bin
|
||||
obj
|
||||
|
30
Makefile
Normal file
30
Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
SRC_DIR := src
|
||||
OBJ_DIR := obj
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/hellomake
|
||||
SRC := $(wildcard $(SRC_DIR)/*.c)
|
||||
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||
|
||||
CPPFLAGS := -Iinclude -MMD -MP
|
||||
CFLAGS := -Wall
|
||||
LDFLAGS := -Llib
|
||||
LDLIBS := -lm
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(EXE)
|
||||
|
||||
$(EXE): $(OBJ) | $(BIN_DIR)
|
||||
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN_DIR) $(OBJ_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
|
||||
|
||||
-include $(OBJ:.o=.d)
|
15
src/hellolog.c
Normal file
15
src/hellolog.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "log.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
log_set_quiet(true);
|
||||
FILE *f;
|
||||
f=fopen("/tmp/test.log", "a");
|
||||
log_add_fp(f, 1);
|
||||
log_trace("TRACE - Hello %s", "world");
|
||||
log_debug("DEBUG - Hello %s", "world");
|
||||
log_info("INFO - Hello %s", "world");
|
||||
log_warn("WARNING - Hello %s", "world");
|
||||
log_error("ERROR - Hello %s", "world");
|
||||
log_fatal("FATAL - Hello %s", "world");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user