Skip to content

Commit

Permalink
Duplicate debug messages into syslog.
Browse files Browse the repository at this point in the history
May be helpful when running detached from tty.
  • Loading branch information
relan committed Jul 4, 2021
1 parent e53fa1b commit ab19b44
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libexfat/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,22 @@ void exfat_warn(const char* format, ...)
*/
void exfat_debug(const char* format, ...)
{
va_list ap;
va_list ap, aq;

va_start(ap, format);
va_copy(aq, ap);

fflush(stdout);
fputs("DEBUG: ", stderr);
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
fputs(".\n", stderr);

#ifdef __ANDROID__
__android_log_vprint(ANDROID_LOG_DEBUG, PACKAGE, format, aq);
#else
if (!isatty(STDERR_FILENO))
vsyslog(LOG_DEBUG, format, aq);
#endif
va_end(aq);
}

0 comments on commit ab19b44

Please sign in to comment.