mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Add most of the stdout output also to stdlog
This commit is contained in:
parent
0a657cbdb0
commit
60f0c2494f
3 changed files with 20 additions and 10 deletions
|
|
@ -293,7 +293,11 @@ void os_init(int opt);
|
|||
void os_done(void);
|
||||
|
||||
/**
|
||||
* Global log file.
|
||||
* Log file.
|
||||
*
|
||||
* This stream if fully buffered.
|
||||
*
|
||||
* If no log file is selected, it's 0.
|
||||
*/
|
||||
FILE* stdlog;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,32 +26,38 @@ void fout(const char* format, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* first output the same message to stdlog and flush it */
|
||||
/* to have the same behaviour of stdout */
|
||||
if (stdlog) {
|
||||
va_start(ap, format);
|
||||
fprintf(stdlog, "stdout: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
va_end(ap);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdout, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void ferr(const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* first output the same message to stdlog and flush it */
|
||||
/* to have the same behaviour of stderr */
|
||||
if (stdlog) {
|
||||
va_start(ap, format);
|
||||
fprintf(stdlog, "stderr: ");
|
||||
vfprintf(stdlog, format, ap);
|
||||
fflush(stdlog);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void flog(const char* format, ...)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
* Messages are in human readable format.
|
||||
* They must include the full line output and terminate with '\n'.
|
||||
*
|
||||
* These messages go in stdout.
|
||||
* These messages go in the log file and in stdout.
|
||||
*/
|
||||
void fout(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue