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=1683256106; x=1685848106; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=uuM9AH1pOeo9YafWBw4ogm4YEEB6ecayjmkkC3vAsmk=; b=GXQheA9/5K90QOt0zMXnz9NLHQFq3k3U9TT6R3Fs9IK9K0JmKH5xn4E1eCEiWpj540 mGqHU8hxcIWMnvTsS5rjSLAfT6cP9B3OySMLsaYGwO5BJ4rcU7EpGGXQFsphbwjoOmBZ QBPDFKpp1PxAZMiFKdXl2eD6mlzE2SupbxGCnQ5PkNsEBmXm4g/keFVCGUCPhaOjSEpC YFzDe9lMLGspR+WSN5vp2jR0JDkTZCFPGDIsd/WpFZPnZmqkhRWcTIDzJRs78PRVIz0K yG3DjpI9RLumQF16RS7475xhc6AErLjjv2ZeJxcpBrGDKNW896bkS+TPoeX9Q+U13MdE 5pfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683256106; x=1685848106; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uuM9AH1pOeo9YafWBw4ogm4YEEB6ecayjmkkC3vAsmk=; b=mB184eP0UiygR3jk0MnAk8ImSkpaKrDLKOkCT5asQ89gSHHaOnf8+nIW+POQL9rzG8 12ORrqyMmB/ncV8jYAKt9YAFR9xebHH4XT9Iiaz+oU6pJQZ2GGnfQ0iEuCIOPpz/FrHm 2w1M1KJgSBjAF4TUZeQShaWBMaP8+ujuPKDTbwUI/a9V0mCU/dlFdzE0fxTsup8wW7RA uvDNQCYaYlwXwNMrboYsPFW8HcOECf4TCm9PGlbl2zQvwW4lqoec83O+8vnHRBTha0Ai BHDbFY4M0Kk9d7bHO/7zwSuUDWqVvaPlh2HADQxHsTjfoA2P0RQIZz1IuXoITaZ8yt1V vzfw== X-Gm-Message-State: AC+VfDwsH6CVLijpZ211yrKmroQhTfSJdxG351Xx5DhSvKuh3e+WYSQ/ /pICMOesoI73Pxxhs/ofq8OUsgwzSh4= X-Google-Smtp-Source: ACHHUZ5iDo5koGRfekLaVQ4QzVKQ4uO2TuUn84TAWtN4jO6ctnU45eLgcXKjs95mGlCvBYbbCdBlaw== X-Received: by 2002:a81:4f4c:0:b0:54f:1185:b57f with SMTP id d73-20020a814f4c000000b0054f1185b57fmr144615ywb.29.1683256105820; Thu, 04 May 2023 20:08:25 -0700 (PDT) Message-ID: Date: Fri, 5 May 2023 06:08:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.10.0 To: make-initrd@lists.altlinux.org References: <6b444ed922286eb3df8f5322b1bddf9c55753eb8.1683200226.git.gladkov.alexey@gmail.com> Content-Language: ru, en-US From: Leonid Krivoshein In-Reply-To: <6b444ed922286eb3df8f5322b1bddf9c55753eb8.1683200226.git.gladkov.alexey@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [make-initrd] [PATCH 1/3] Reimplement ueventd 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: Fri, 05 May 2023 03:08:30 -0000 Archived-At: List-Archive: On 5/4/23 16:42, Alexey Gladkov wrote: > [...] > diff --git a/datasrc/ueventd/logging.c b/datasrc/ueventd/logging.c > new file mode 100644 > index 00000000..671f6814 > --- /dev/null > +++ b/datasrc/ueventd/logging.c > @@ -0,0 +1,63 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > + > +#include > +#include > +#include > +#include > +#include > + > +#include "ueventd.h" > + > +#define default_logfile "/var/log/ueventd.log" > + > +int log_priority = LOG_INFO; > + > [...] > +void message(int priority, const char *fmt, ...) > +{ > + va_list ap; > + va_start(ap, fmt); > + if (priority <= log_priority) { > + time_t ts = time(NULL); > + struct tm *t = localtime(&ts); > + fprintf(stderr, "[%04d-%02d-%02d %02d:%02d:%02d] %s: ", > + t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, > + t->tm_hour, t->tm_min, t->tm_sec, > + program_invocation_short_name); Кажется, есть риск спутать сообщения от разных потоков, тут должен быть целостный буферизированный вывод через snprintf(). Мой комментарий как раз в месте потенциального разрыва. Если журналирование выстраивается в один поток выполнения, проблемы нет. > + vfprintf(stderr, fmt, ap); > + fprintf(stderr, "\n"); > + } > + va_end(ap); > +} > [...] -- WBR, Leonid Krivoshein.