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=1683306166; x=1685898166; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=lEqF7gBJidKBzl3GD/3unpbZ4NRqwwYOiHrOE8PmtYE=; b=HPs3P87uJq6ZkmDlCSMgkQXju4TtauZVn9kpydnKKkflNmkJFicOVA0A2yqgkrcnnL 7h6bXmDtxWDY0SxLoCC9cEgMEDN5A110PITdjUGF4siIfFefEk9IrVBlkXUHVXmx1Fe/ V37qViW0rxj/PcqavHnFcrGhLKZLaWOchmA1w0wgPQ9onsR3gVve43B6/VqfYwY0PPbE ZOxLI3pTndIlAINCwsFem+AtXPQq7gAvdjmcEnqk9bW+b+tIsfH7xtI8OmNPtX4fqi2x 8BR7vdBNkAAO+SRafkdhky+3cYlvdzYtohOe6sD2KPlPFUTjwA+FTp84MdIg01dfIYCn 3Oeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683306166; x=1685898166; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lEqF7gBJidKBzl3GD/3unpbZ4NRqwwYOiHrOE8PmtYE=; b=WnPe2IdEH/dxHSYyphuZUoKDGhAfN1GxMGYOUu0hIVogbq/1CxOsAHTFWYYtsPCxVO P0GEiagHr1wbHCjbRfGKuUN1pkRETf+/DRGGmhAnrhaqceBaex50idmPS2p5Ruebmffx jsY7YKrm2Dfy9ZIyB0z85/lxjpYE+/Q94Bg2mhm4zM9znChKDlD91viutiOnhQmVEosv pmJAYZhqxYI3bnf6s90H5aPkM+/ZVeSTKwru7FqQtvKs4xPhi0dl/fVw3UYIponYUSJy ISkWfK9elqW7UBlmsBje50gcWRmYUYLUTnyi6YPURwPXqgTjT/kJE67nc8lUL44sld09 HQUg== X-Gm-Message-State: AC+VfDwv1x5gIOItyY2Jm1UMKO1rqtjThWnLfW5n3kuobyxJq9+IOgN2 Pn5io+dRk3UjTzq1cfC2bEyak5ZG+Ec= X-Google-Smtp-Source: ACHHUZ4OLBjUoD6rHHRijs5fM2JRaSJS6e7EWkMUdY7GVWvUS0S8LHxnYnMpTv/AmJvZCsYTjGAQWg== X-Received: by 2002:a7b:cb07:0:b0:3f1:7129:6b25 with SMTP id u7-20020a7bcb07000000b003f171296b25mr1644171wmj.18.1683306165743; Fri, 05 May 2023 10:02:45 -0700 (PDT) Date: Fri, 5 May 2023 19:02:40 +0200 From: Alexey Gladkov To: make-initrd@lists.altlinux.org Message-ID: References: <6b444ed922286eb3df8f5322b1bddf9c55753eb8.1683200226.git.gladkov.alexey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 17:02:48 -0000 Archived-At: List-Archive: On Fri, May 05, 2023 at 06:08:25AM +0300, Leonid Krivoshein wrote: > > 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(). Мой комментарий как > раз в месте потенциального разрыва. Если журналирование выстраивается в > один поток выполнения, проблемы нет. Ты абсолютно прав. Тут вообще всё нужно делать иначе. Это нужно делать через writev например. > > + vfprintf(stderr, fmt, ap); > > + fprintf(stderr, "\n"); > > + } > > + va_end(ap); > > +} > > [...] > > > -- > WBR, Leonid Krivoshein. > _______________________________________________ > Make-initrd mailing list > Make-initrd@lists.altlinux.org > https://lists.altlinux.org/mailman/listinfo/make-initrd -- Rgrds, legion