add logging
This commit is contained in:
@@ -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 */
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "stk.h"
|
#include "stk.h"
|
||||||
#include <stdio.h>
|
#include "stk_log.h"
|
||||||
|
|
||||||
int stk_init(void)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stk_shutdown(void)
|
int stk_shutdown(void)
|
||||||
{
|
{
|
||||||
printf("stk shutdown\n");
|
stk_log(stdout, "stk shutdown");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user