diff --git a/include/stk_log.h b/include/stk_log.h new file mode 100644 index 0000000..c66fe36 --- /dev/null +++ b/include/stk_log.h @@ -0,0 +1,16 @@ +#ifndef STK_LOG_H +#define STK_LOG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void stk_log(FILE *fp, const char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* STK_LOG_H */ diff --git a/src/stk.c b/src/stk.c index 3d08898..3dbaf3b 100644 --- a/src/stk.c +++ b/src/stk.c @@ -1,14 +1,14 @@ #include "stk.h" -#include +#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; } diff --git a/src/stk_log.c b/src/stk_log.c new file mode 100644 index 0000000..2cb9ad2 --- /dev/null +++ b/src/stk_log.c @@ -0,0 +1,14 @@ +#include "stk_log.h" +#include +#include + +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); +}