From f8217d240d598f39f70047f7a623dd46312542c6 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 4 Dec 2021 16:01:12 -0800 Subject: Initial commit. --- log/CMakeLists.txt | 9 +++++++++ log/README.md | 1 + log/include/log/log.h | 19 +++++++++++++++++++ log/src/log.c | 1 + 4 files changed, 30 insertions(+) create mode 100644 log/CMakeLists.txt create mode 100644 log/README.md create mode 100644 log/include/log/log.h create mode 100644 log/src/log.c (limited to 'log') 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 @@ +cmake_minimum_required(VERSION 3.16) + +add_library(log + src/log.c) + +target_include_directories(log PUBLIC + include) + +target_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 @@ +#pragma once + +// Current implementation assumes a posix environment. + +#include + +typedef enum { LogDebug, LogInfo, LogWarning, LogError } LogLevel; + +#define LOG(tag, ...) \ + { \ + printf("[%s] %s:%d: ", #tag, __FILE__, __LINE__); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } + +#define LOGD(...) LOG(DEBUG, __VA_ARGS__) +#define LOGI(...) LOG(INFO, __VA_ARGS__) +#define LOGW(...) LOG(WARN, __VA_ARGS__) +#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 -- cgit v1.2.3