From 646c834492a419a96b4032c230e842d27f87e997 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 14 Feb 2021 10:01:02 -0500 Subject: Log to /var/log/apk.log This adds a log file at /var/log/apk.log. On each run, apk's version information and the current date & time are written to this file, followed by any normal apk output. --- src/apk_print.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/apk_print.h') diff --git a/src/apk_print.h b/src/apk_print.h index ec766ed..132fd8c 100644 --- a/src/apk_print.h +++ b/src/apk_print.h @@ -30,11 +30,15 @@ void apk_url_parse(struct apk_url_print *, const char *); struct apk_out { int verbosity; unsigned int width, last_change; - FILE *out, *err; + FILE *out, *err, *log; }; static inline int apk_out_verbosity(struct apk_out *out) { return out->verbosity; } +// Pass this as the prefix to skip logging to the console (but still write to +// the log file). +#define APK_OUT_LOG_ONLY ((const char*)-1) + #define apk_err(out, args...) do { apk_out_fmt(out, "ERROR: ", args); } while (0) #define apk_out(out, args...) do { apk_out_fmt(out, NULL, args); } while (0) #define apk_warn(out, args...) do { if (apk_out_verbosity(out) >= 0) { apk_out_fmt(out, "WARNING: ", args); } } while (0) @@ -44,6 +48,7 @@ static inline int apk_out_verbosity(struct apk_out *out) { return out->verbosity void apk_out_reset(struct apk_out *); void apk_out_fmt(struct apk_out *, const char *prefix, const char *format, ...); +void apk_out_log_argv(struct apk_out *, char **argv); struct apk_progress { struct apk_out *out; -- cgit v1.2.3-70-g09d2