1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Add logging functions

Named "vlogs" because they're logs for VVVVVV. Also it's a funny name.
This commit is contained in:
Misa 2021-02-23 00:54:45 -08:00 committed by Misa Elizabeth Kai
parent ac0644a70a
commit d9737589de
3 changed files with 70 additions and 0 deletions

View file

@ -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
)

View file

@ -0,0 +1,50 @@
#include <stdarg.h>
#include <stdio.h>
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;
}

View file

@ -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 */