flog: new helper function for debugging to file

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-02-26 09:09:34 +01:00
parent 45a374b50a
commit 80e4f025d3
2 changed files with 23 additions and 0 deletions
+22
View File
@@ -130,6 +130,28 @@ done:
va_end(ap);
}
/*
* Log to file, intended for debug only.
*/
void flog(char *file, const char *fmt, ...)
{
char fn[80];
va_list ap;
FILE *fp;
snprintf(fn, sizeof(fn), "/tmp/%s.log", file);
fp = fopen(fn, "a");
if (!fp)
return;
va_start(ap, fmt);
vfprintf(fp, fmt, ap);
va_end(ap);
fclose(fp);
}
/**
* Local Variables:
* indent-tabs-mode: t
+1
View File
@@ -51,5 +51,6 @@ void log_exit (void);
void log_debug (void);
void logit (int prio, const char *fmt, ...);
void flog (char *file, const char *fmt, ...);
#endif /* FINIT_LOG_H_ */