create project structure
This commit is contained in:
13 files changed
+221
No files matched your search
@@ -0,0 +1,23 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -g -fPIC
|
||||
LDFLAGS =
|
||||
|
||||
LIBRARY = libmysyslog-text.a
|
||||
OBJ = src/log_text.o
|
||||
|
||||
all: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(OBJ)
|
||||
ar rcs $@ $^
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(LIBRARY)
|
||||
|
||||
deb:
|
||||
# Deb package building logic
|
||||
|
||||
install: $(LIBRARY)
|
||||
cp $(LIBRARY) /usr/local/lib
|
||||
ldconfig
|
||||
|
||||
.PHONY: all clean deb install
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef LOG_TEXT_H
|
||||
#define LOG_TEXT_H
|
||||
|
||||
#include "mysyslog.h"
|
||||
|
||||
void log_text(const char* msg, LogLevel level, const char* path);
|
||||
|
||||
#endif // LOG_TEXT_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "log_text.h"
|
||||
|
||||
void log_text(const char* msg, LogLevel level, const char* path) {
|
||||
FILE* f = fopen(path, "a");
|
||||
if (!f) return;
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm* tm_info = localtime(&t);
|
||||
|
||||
// Format log entry
|
||||
fprintf(f, "%ld %d example-app %s\n", t, level, msg);
|
||||
fclose(f);
|
||||
}
|
||||
Reference in new issue
Block a user