From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683402310; x=1685994310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zbQY66AK30hqYgQNk5nBsqqvn9cVUgFWcl2ypKwBnaQ=; b=T+JWLVrlbD4GbIFuu8zlB+7yQLrteeoO05PtuXaVPAS7QDEoqxWL9wTiQLFYESEuCB CIqQOPkKDSGVCAtQ0WAzWHmRIXpWNXXGvTmkFWaUaxhtzHR48pvzAszXW6q9R4kyNnQB FjYqamc/1xoqq5wi0c+BYoL6TAJ2fEDUcUaN9Jnc/+Y77aOE8L0Dbph00EdmMzWXzesv QH3+G5kjz1zn39RLoJrmqA9xJoCG60TVMERHvA8/kaUnFMUbnxd3bXm2lxIzUGZD/+cB laPzv93qHDW140J4IQRLx55haBf7v2i9iBUk560uN4rShgkB18WFLoro7WwxwHBrx9lk IdkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683402310; x=1685994310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zbQY66AK30hqYgQNk5nBsqqvn9cVUgFWcl2ypKwBnaQ=; b=jIB6BrkxXNdUdDvsjwn3fbAoos+Zh6NH6tA2umBP2H4ILiXE60nYkpLhzrpYB9Cpcs ApF7EsaLvm8Mu5SsMnJLqgPeU7extTIgS0zX2YkLUSM4/2mPru1fS/oLXXbGq0HkhF5V RjmEZXmXOSvX6xe+gHE4uxrqb8Ps1g4VopN/GW3hOM5PuE8DciBnU3QjuAXKJgxeH7rQ 6ZQEcYQUbRo/zzKtjmHGZeiL2rFoTgKuLEFVOj9MuTh37j2yzEDnuBpnbPUEfVSiMtXr /IRHwFUllfkvOQpEa1eEoWBBVLl46tSr0esP1yMRFBjL5zgDzPcDGTSzxCcemBoEHOc3 yIAw== X-Gm-Message-State: AC+VfDyq2set++ERx3+e0zrdLnL4+pqIXWq7/cXsQCpDQ1EVEpq9PS8R qeoXouXQ5hM45l7f+gMA/Dd4E8ytNkY= X-Google-Smtp-Source: ACHHUZ5Vhz2qYAvQUwZa6RMyV79GtfvMXOj5S4zi8aHQ7JmPHyyZdcmJqfhT5y3XhwrXt8yVipWOWg== X-Received: by 2002:adf:dec6:0:b0:2cf:f279:378f with SMTP id i6-20020adfdec6000000b002cff279378fmr3735092wrn.44.1683402310694; Sat, 06 May 2023 12:45:10 -0700 (PDT) From: Alexey Gladkov To: make-initrd@lists.altlinux.org Date: Sat, 6 May 2023 21:45:03 +0200 Message-Id: <20230506194504.1471267-3-gladkov.alexey@gmail.com> X-Mailer: git-send-email 2.33.7 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [make-initrd] ueventd: Pass the program name when initializing the logger X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 May 2023 19:45:15 -0000 Archived-At: List-Archive: Signed-off-by: Alexey Gladkov --- datasrc/ueventd/logging.c | 11 +++++++---- datasrc/ueventd/ueventd.c | 2 +- datasrc/ueventd/ueventd.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/datasrc/ueventd/logging.c b/datasrc/ueventd/logging.c index 525ff7fd..ac316aab 100644 --- a/datasrc/ueventd/logging.c +++ b/datasrc/ueventd/logging.c @@ -10,6 +10,7 @@ int log_priority = LOG_INFO; int log_fd = STDERR_FILENO; +const char *log_progname = NULL; int rd_logging_level(const char *name) { @@ -20,10 +21,11 @@ int rd_logging_level(const char *name) return log_priority; } -void rd_logging_init(int fd, int loglevel) +void rd_logging_init(int fd, int loglevel, const char *progname) { log_priority = loglevel; log_fd = fd; + log_progname = progname; } void rd_logging_close(void) @@ -37,10 +39,11 @@ void rd_message(int priority, const char *fmt, ...) if (priority <= log_priority) { time_t ts = time(NULL); struct tm *t = localtime(&ts); - dprintf(log_fd, "[%04d-%02d-%02d %02d:%02d:%02d] %s: ", + dprintf(log_fd, "[%04d-%02d-%02d %02d:%02d:%02d] ", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec, - program_invocation_short_name); + t->tm_hour, t->tm_min, t->tm_sec); + if (log_progname) + dprintf(log_fd, "%s: ", log_progname); vdprintf(log_fd, fmt, ap); dprintf(log_fd, "\n"); } diff --git a/datasrc/ueventd/ueventd.c b/datasrc/ueventd/ueventd.c index d015d3da..0ce5be00 100644 --- a/datasrc/ueventd/ueventd.c +++ b/datasrc/ueventd/ueventd.c @@ -491,7 +491,7 @@ int main(int argc, char **argv) stderr = cons; } - rd_logging_init(fileno(stderr), loglevel); + rd_logging_init(fileno(stderr), loglevel, program_invocation_short_name); rd_info("starting server ..."); diff --git a/datasrc/ueventd/ueventd.h b/datasrc/ueventd/ueventd.h index a783d48d..ddba98bf 100644 --- a/datasrc/ueventd/ueventd.h +++ b/datasrc/ueventd/ueventd.h @@ -56,7 +56,7 @@ extern int is_dot_dir(struct dirent *ent) __attribute__((nonnull(1))); #include #include -extern void rd_logging_init(int log_fd, int level); +extern void rd_logging_init(int log_fd, int level, const char *progname); extern void rd_logging_close(void); extern int rd_logging_level(const char *lvl) __attribute__((nonnull(1))); extern void rd_message(int priority, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -- 2.33.7