From d9737589dee5b8830775da01d795dd282f831511 Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 23 Feb 2021 00:54:45 -0800 Subject: [PATCH] Add logging functions Named "vlogs" because they're logs for VVVVVV. Also it's a funny name. --- desktop_version/CMakeLists.txt | 1 + desktop_version/src/Vlogging.c | 50 ++++++++++++++++++++++++++++++++++ desktop_version/src/Vlogging.h | 19 +++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 desktop_version/src/Vlogging.c create mode 100644 desktop_version/src/Vlogging.h diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 41534cae..a5b0d130 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -112,6 +112,7 @@ set(VVV_SRC src/GlitchrunnerMode.c src/Network.c src/ThirdPartyDeps.c + src/Vlogging.c src/Xoshiro.c ../third_party/physfs/extras/physfsrwops.c ) diff --git a/desktop_version/src/Vlogging.c b/desktop_version/src/Vlogging.c new file mode 100644 index 00000000..ed7588be --- /dev/null +++ b/desktop_version/src/Vlogging.c @@ -0,0 +1,50 @@ +#include +#include + +int vlog_info(const char* text, ...) +{ + va_list list; + int retval; + + printf("[INFO] "); + + va_start(list, text); + retval = vprintf(text, list); + va_end(list); + + putchar('\n'); + + return retval; +} + +int vlog_warn(const char* text, ...) +{ + va_list list; + int retval; + + fprintf(stderr, "[WARN] "); + + va_start(list, text); + retval = vfprintf(stderr, text, list); + va_end(list); + + fputc('\n', stderr); + + return retval; +} + +int vlog_error(const char* text, ...) +{ + va_list list; + int retval; + + fprintf(stderr, "[ERROR] "); + + va_start(list, text); + retval = vfprintf(stderr, text, list); + va_end(list); + + fputc('\n', stderr); + + return retval; +} diff --git a/desktop_version/src/Vlogging.h b/desktop_version/src/Vlogging.h new file mode 100644 index 00000000..3189fadd --- /dev/null +++ b/desktop_version/src/Vlogging.h @@ -0,0 +1,19 @@ +#ifndef VLOGGING_H +#define VLOGGING_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +int vlog_info(const char* text, ...); + +int vlog_warn(const char* text, ...); + +int vlog_error(const char* text, ...); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* VLOGGING_H */