add logging

This commit is contained in:
2025-10-21 00:10:51 +02:00
parent a82fb80a99
commit 8b26742c63
3 changed files with 33 additions and 3 deletions
+16
View File
@@ -0,0 +1,16 @@
#ifndef STK_LOG_H
#define STK_LOG_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
void stk_log(FILE *fp, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif /* STK_LOG_H */
+3 -3
View File
@@ -1,14 +1,14 @@
#include "stk.h"
#include <stdio.h>
#include "stk_log.h"
int stk_init(void)
{
printf("stk initialized v%s\n", STK_VERSION_STRING);
stk_log(stdout, "[stk] stk initialized v%s!", STK_VERSION_STRING);
return 0;
}
int stk_shutdown(void)
{
printf("stk shutdown\n");
stk_log(stdout, "stk shutdown");
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
#include "stk_log.h"
#include <stdarg.h>
#include <stdio.h>
void stk_log_file(FILE *fp, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(fp, fmt, args);
fputc('\n', fp);
va_end(args);
}