public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Gabriel Goller <g.goller@proxmox.com>
Cc: Lukas Wagner <l.wagner@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox v2 1/4] log: rename/move init functions
Date: Tue, 11 Feb 2025 10:28:42 +0100	[thread overview]
Message-ID: <iidtwwpusvqkcqw6sh7e7mqqnlhu37icz5k77ps5wro2nenr7b@gqi7k24dsw4n> (raw)
In-Reply-To: <2cugfnfjfv2robousxhdshdu3rxmyg3bnfdazoyagvn5gglatl@6x4trum24nak>

On Tue, Feb 11, 2025 at 10:22:44AM +0100, Wolfgang Bumiller wrote:
> On Mon, Feb 10, 2025 at 05:42:35PM +0100, Gabriel Goller wrote:
> > On 10.02.2025 15:37, Wolfgang Bumiller wrote:
> > > On Mon, Dec 09, 2024 at 11:46:03AM +0100, Gabriel Goller wrote:
> > > > +/// Inits a new tracing logger that prints to stderr or tasklog with the logging level specified in the
> > > > +/// environment variable `env_var`.
> > > > +///
> > > > +/// This logger is task-aware, which means if we are in a PBS task, we will retrieve the task-file
> > > > +/// and write to it. We'll only write to stderr if we are not in a task. If `env_var` doesn't exist
> > > > +/// or can't be read, use the `default_log_level`. The output will be very plain: no ansi, no
> > > > +/// timestamp, no level, just the message and it's
> > > > +/// fields.
> > > > +pub fn stderr_or_tasklog(
> > > > +    env_var: &str,
> > > > +    default_log_level: LevelFilter,
> > > > +) -> Result<(), anyhow::Error> {
> > > > +    let log_level = get_env_variable(env_var, default_log_level);
> > > > +
> > > > +    let registry = tracing_subscriber::registry()
> > > > +        .with(
> > > > +            plain_stderr_layer()
> > > > +                .with_filter(filter_fn(|_metadata| !LogContext::exists()))
> > > 
> > > ^ This condition misses the `Level::ERROR` comparison while being
> > > suggested as a replacement for `init_cli_logger` which had it (not
> > > visible in the patch context lines, but it's there).
> > > If this is done on purpose, please explain it in the commit message.
> > 
> > Oops, yeah my bad, this should be
> > 
> >     !LogContext::exists() || *metadata.level() == Level::ERROR
> > 
> > What do you think about the rest of the patch? I tried to implement this
> > with a builder pattern as well, but it turned out to be quite tricky
> > moving the layers around so I just wrote a ton of functions with long
> > names :(
> 
> The rest seems fine.
> It does look like it should be mostly a builder-pattern thing (as it
> kind of already is, with the final 2 lines being a kind of `.apply()`,
> but with the names being showing their intended use, it's fine for an
> `init` module to have specific common setups like this (`init_cli_…`,
> `…with_pve_format`, etc.)
> 
> Perhaps the journal/tasklog one could be named "init_daemon_log" (or
> just have an alias under that name)...

Sorry, I was reading it backwards, we're getting rid of those names...
That just goes to show I didn't properly think about this... :-)

Now, first of all, having the "descriptive" names there makes sense.
With the `pve` specific function we then still have a rather specific
one.
Therefore, with a specific `init` module, it would IMO be fine to have
situation-specific names for common setups.

Unless we can actually come up with a builder-pattern variant.
Perhaps it would have to be the Layer type rather than the subscriber
we'd need to turn into a builder, while having its final "apply" create
the subscriber and register it and initialize the LogTracer.


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

  reply	other threads:[~2025-02-11  9:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 10:46 [pbs-devel] [PATCH proxmox{, -backup, -perl-rs} v2 0/4] Rename/Move logging init helper Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox v2 1/4] log: rename/move init functions Gabriel Goller
2025-02-10 14:37   ` Wolfgang Bumiller
2025-02-10 16:42     ` Gabriel Goller
2025-02-11  9:22       ` Wolfgang Bumiller
2025-02-11  9:28         ` Wolfgang Bumiller [this message]
2025-02-17 13:08           ` Gabriel Goller
2025-02-17 13:38             ` Wolfgang Bumiller
2025-02-17 14:12               ` Gabriel Goller
2025-02-17 14:51                 ` Wolfgang Bumiller
2025-02-17 15:21                   ` Gabriel Goller
2025-02-18 10:06                     ` Wolfgang Bumiller
2025-02-18 16:15                       ` Gabriel Goller
2025-02-11  9:31         ` Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox v2 2/4] log: add logger for perlmod crates Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox-backup v2 3/4] log: use new init functions Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox-perl-rs v2 4/4] log: use new init function, print to stderr and journald Gabriel Goller
2025-01-09 10:09 ` [pbs-devel] [PATCH proxmox{, -backup, -perl-rs} v2 0/4] Rename/Move logging init helper Lukas Wagner
2025-01-14  8:43 ` Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iidtwwpusvqkcqw6sh7e7mqqnlhu37icz5k77ps5wro2nenr7b@gqi7k24dsw4n \
    --to=w.bumiller@proxmox.com \
    --cc=g.goller@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal