This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6a6a1422388059727dd642cbd5b9a4759fdc4a53

commit 6a6a1422388059727dd642cbd5b9a4759fdc4a53
Author: Guillem Jover <[email protected]>
AuthorDate: Sun Apr 19 16:30:44 2020 +0200

    u-a: Move logging function close to output functions
---
 debian/changelog            |  1 +
 utils/update-alternatives.c | 55 ++++++++++++++++++++++-----------------------
 2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index cb7db7276..65c6e711a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -117,6 +117,7 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
     - scripts: Refactor shell error handling into a shell library
     - Reformat shell code to follow the coding style.
     - update-alternatives: Parametrize option names in output strings.
+    - update-alternatives: Move logging function close to output functions.
   * Build system:
     - Handle .git being a plain file when getting the dpkg tree version.
     - Add debian/changelog as a Changes file to the CPAN distribution.
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 5637e3819..3de252f9e 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -100,6 +100,7 @@ enum output_mode {
 /* Action to perform */
 static enum action action = ACTION_NONE;
 static const char *log_file = LOGDIR "/alternatives.log";
+static FILE *fh_log = NULL;
 /* Skip alternatives properly configured in auto mode (for --config) */
 static int opt_skip_auto = 0;
 static int opt_verbose = OUTPUT_NORMAL;
@@ -286,6 +287,32 @@ pr(char const *fmt, ...)
        printf("\n");
 }
 
+static void DPKG_ATTR_PRINTF(1)
+log_msg(const char *fmt, ...)
+{
+       va_list args;
+
+       if (fh_log == NULL) {
+               fh_log = fopen(log_file, "a");
+               if (fh_log == NULL && errno != EACCES)
+                       syserr(_("cannot append to '%s'"), log_file);
+       }
+
+       if (fh_log) {
+               char timestamp[64];
+               time_t now;
+
+               time(&now);
+               strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S",
+                        localtime(&now));
+               fprintf(fh_log, "%s %s: ", PROGNAME, timestamp);
+               va_start(args, fmt);
+               vfprintf(fh_log, fmt, args);
+               va_end(args);
+               fprintf(fh_log, "\n");
+       }
+}
+
 static void *
 xmalloc(size_t size)
 {
@@ -437,34 +464,6 @@ admindir_init(void)
        return xasprintf("%s/%s", basedir, "alternatives");
 }
 
-static FILE *fh_log = NULL;
-
-static void DPKG_ATTR_PRINTF(1)
-log_msg(const char *fmt, ...)
-{
-       va_list args;
-
-       if (fh_log == NULL) {
-               fh_log = fopen(log_file, "a");
-               if (fh_log == NULL && errno != EACCES)
-                       syserr(_("cannot append to '%s'"), log_file);
-       }
-
-       if (fh_log) {
-               char timestamp[64];
-               time_t now;
-
-               time(&now);
-               strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S",
-                        localtime(&now));
-               fprintf(fh_log, "%s %s: ", PROGNAME, timestamp);
-               va_start(args, fmt);
-               vfprintf(fh_log, fmt, args);
-               va_end(args);
-               fprintf(fh_log, "\n");
-       }
-}
-
 static int
 spawn(const char *prog, const char *args[])
 {

-- 
Dpkg.Org's dpkg

Reply via email to