From 5fd9f4fef9d2f2642079dfa7b87ee10e28783e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rostislav=20St=C5=99=C3=ADbrn=C3=BD?= Date: Fri, 4 Nov 2022 11:51:25 +0100 Subject: [PATCH] example test --- .gitignore | 3 +++ Makefile | 30 ++++++++++++++++++++++++++++++ src/hellolog.c | 15 +++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/hellolog.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a382af2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin +obj + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b2145eb --- /dev/null +++ b/Makefile @@ -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) diff --git a/src/hellolog.c b/src/hellolog.c new file mode 100644 index 0000000..1bfd522 --- /dev/null +++ b/src/hellolog.c @@ -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"); +} +