aboutsummaryrefslogtreecommitdiff
path: root/log
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2021-12-04 16:01:12 -0800
committer3gg <3gg@shellblade.net>2021-12-04 16:01:12 -0800
commitf8217d240d598f39f70047f7a623dd46312542c6 (patch)
tree4e40843d665e388416c1226f739c2b8c0b8da736 /log
parent5f6ea503cdb6ad4a95b679672a1ad324d96c89a5 (diff)
Initial commit.
Diffstat (limited to 'log')
-rw-r--r--log/CMakeLists.txt9
-rw-r--r--log/README.md1
-rw-r--r--log/include/log/log.h19
-rw-r--r--log/src/log.c1
4 files changed, 30 insertions, 0 deletions
diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt
new file mode 100644
index 0000000..490c78c
--- /dev/null
+++ b/log/CMakeLists.txt
@@ -0,0 +1,9 @@
1cmake_minimum_required(VERSION 3.16)
2
3add_library(log
4 src/log.c)
5
6target_include_directories(log PUBLIC
7 include)
8
9target_compile_options(log PRIVATE -Wall -Wextra)
diff --git a/log/README.md b/log/README.md
new file mode 100644
index 0000000..1c70225
--- /dev/null
+++ b/log/README.md
@@ -0,0 +1 @@
# Logging Library
diff --git a/log/include/log/log.h b/log/include/log/log.h
new file mode 100644
index 0000000..41a83cc
--- /dev/null
+++ b/log/include/log/log.h
@@ -0,0 +1,19 @@
1#pragma once
2
3// Current implementation assumes a posix environment.
4
5#include <stdio.h>
6
7typedef enum { LogDebug, LogInfo, LogWarning, LogError } LogLevel;
8
9#define LOG(tag, ...) \
10 { \
11 printf("[%s] %s:%d: ", #tag, __FILE__, __LINE__); \
12 printf(__VA_ARGS__); \
13 printf("\n"); \
14 }
15
16#define LOGD(...) LOG(DEBUG, __VA_ARGS__)
17#define LOGI(...) LOG(INFO, __VA_ARGS__)
18#define LOGW(...) LOG(WARN, __VA_ARGS__)
19#define LOGE(...) LOG(ERROR, __VA_ARGS__)
diff --git a/log/src/log.c b/log/src/log.c
new file mode 100644
index 0000000..0e0248e
--- /dev/null
+++ b/log/src/log.c
@@ -0,0 +1 @@
#include <log/log.h>