From: Lukas Wagner <l.wagner@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Gabriel Goller <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox v5 1/4] proxmox-log: add tracing infrastructure
Date: Tue, 25 Jun 2024 11:04:01 +0200 [thread overview]
Message-ID: <4bcf0824-a75c-40b7-8017-2a1ad690d579@proxmox.com> (raw)
In-Reply-To: <20240625084445.ippvlffwcdniuav7@luna.proxmox.com>
On 2024-06-25 10:44, Gabriel Goller wrote:
> Thanks for the review!
>
> On 24.06.2024 13:10, Lukas Wagner wrote:
>> Just wondering, have you seen/checked out tracing-journald?
>> Would that be interesting for us?
>>
>> https://docs.rs/tracing-journald/latest/tracing_journald/
>
> I packaged it for debian some time ago. It basically does the same as
> the current `syslog` lib and custom subscriber, so we should just be
> able to drop it in. Don't know if that's too much for this series though :). Maybe as a follow-up? What do you think?
tracing-journald seems easy enough to use/set up, so IMHO you could include this in
series.
>
>>> + };
>>> + if let Err(err) = self.file.write_all(line.as_bytes()) {
>>> + // avoid panicking, log methods should not do that
>>> + // FIXME: or, return result???
>>> + log::error!("error writing to log file - {}", err);
>> Since you use `FileLogger` in `SyslogAndTaskLogger` as a tracing logging layer and
>> also setup the `tracing-log` bridge to convert log records to tracing events,
>> wouldn't this lead to recursion?
>
> Good catch!
>
>>> diff --git a/proxmox-log/src/syslog_tasklog_layer.rs b/proxmox-log/src/syslog_tasklog_layer.rs
>>> new file mode 100644
>>> index 00000000..89437caf
>>> --- /dev/null
>>> +++ b/proxmox-log/src/syslog_tasklog_layer.rs
>>> @@ -0,0 +1,106 @@
>>> +use std::fmt::Write as _;
>>> +use std::sync::Arc;
>>> +use std::sync::Mutex;
>>> +
>>> +use syslog::{Formatter3164, LoggerBackend};
>>> +use tracing::field::Field;
>>> +use tracing::field::Visit;
>>> +use tracing::Event;
>>> +use tracing::Level;
>>> +use tracing::Subscriber;
>>> +use tracing_subscriber::layer::Context;
>>> +use tracing_subscriber::Layer;
>>> +
>>> +use crate::FileLogger;
>>> +use crate::LOGGER;
>>> +use crate::WARN_COUNTER;
>>> +
>>> +pub struct SyslogAndTasklogLayer {
>>> + syslog_logger: Arc<Mutex<syslog::Logger<LoggerBackend, Formatter3164>>>,
>>> +}
>>> +
>>> +impl SyslogAndTasklogLayer {
>>> + pub fn new(application_name: String) -> Self {
>>> + let formatter = Formatter3164 {
>>> + facility: syslog::Facility::LOG_DAEMON,
>>> + process: application_name,
>>> + ..Formatter3164::default()
>>> + };
>>> +
>>> + // we panic here if we can't initialize the syslogger
>>> + let logger = syslog::unix(formatter)
>>
>> Maybe explain why it is okay to panic in this case? (is it?)
>
> I think it's reasonable to not start if we can't write to the syslog.
> Either way this was done a long time before me, so I didn't change it :)
Fair, I did not really check what was copied and what was authored by you ;)
But yeah, I think it is reasonable to not start if you fail to set up logging.
--
- Lukas
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-06-25 9:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 13:56 [pbs-devel] [PATCH proxmox{, -backup} v5 0/4] proxmox-log introduction Gabriel Goller
2024-06-13 13:56 ` [pbs-devel] [PATCH proxmox v5 1/4] proxmox-log: add tracing infrastructure Gabriel Goller
2024-06-24 11:10 ` Lukas Wagner
2024-06-25 8:44 ` Gabriel Goller
2024-06-25 9:04 ` Lukas Wagner [this message]
2024-06-26 7:55 ` Fabian Grünbichler
2024-06-13 13:56 ` [pbs-devel] [PATCH proxmox v5 2/4] enable tracing logger, remove task_log macros Gabriel Goller
2024-06-24 11:09 ` Lukas Wagner
2024-06-25 8:49 ` Gabriel Goller
2024-06-13 13:56 ` [pbs-devel] [PATCH proxmox-backup v5 3/4] switch from task_log! macro to tracing Gabriel Goller
2024-06-24 11:10 ` Lukas Wagner
2024-06-13 13:56 ` [pbs-devel] [PATCH proxmox-backup v5 4/4] api: " Gabriel Goller
2024-06-24 11:13 ` [pbs-devel] [PATCH proxmox{, -backup} v5 0/4] proxmox-log introduction Lukas Wagner
2024-06-26 13:10 ` 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=4bcf0824-a75c-40b7-8017-2a1ad690d579@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=g.goller@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