public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH] log: ignore to_stdout parameter
@ 2024-11-27 11:46 Gabriel Goller
  2024-11-27 12:33 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Goller @ 2024-11-27 11:46 UTC (permalink / raw)
  To: pbs-devel; +Cc: Thomas Lamprecht

This parameter causes the FileLogger to duplicate the log output to
stdout. This causes duplicate output on proxmox-backup-manager because
this is now handled by tracing. This should be removed completely in the
future.
In the worst case this will only result in missing log lines on stdout
(which is visible only on proxmox-backup-manager/client invocations
anyway).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-log/src/file_logger.rs | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs
index c3648976b690..ab3072e4d477 100644
--- a/proxmox-log/src/file_logger.rs
+++ b/proxmox-log/src/file_logger.rs
@@ -103,11 +103,12 @@ impl FileLogger {
     pub fn log<S: AsRef<str>>(&mut self, msg: S) {
         let msg = msg.as_ref();
 
-        if self.options.to_stdout {
-            let mut stdout = std::io::stdout();
-            let _ = stdout.write_all(msg.as_bytes());
-            let _ = stdout.write_all(b"\n");
-        }
+        // TODO: remove whole to_stdout option
+        //if self.options.to_stdout {
+        //    let mut stdout = std::io::stdout();
+        //    let _ = stdout.write_all(msg.as_bytes());
+        //    let _ = stdout.write_all(b"\n");
+        //}
 
         let line = if self.options.prefix_time {
             let now = proxmox_time::epoch_i64();
@@ -128,16 +129,18 @@ impl FileLogger {
 
 impl std::io::Write for FileLogger {
     fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
-        if self.options.to_stdout {
-            let _ = std::io::stdout().write(buf);
-        }
+        // TODO: remove whole to_stdout option
+        //if self.options.to_stdout {
+        //    let _ = std::io::stdout().write(buf);
+        //}
         self.file.write(buf)
     }
 
     fn flush(&mut self) -> Result<(), std::io::Error> {
-        if self.options.to_stdout {
-            let _ = std::io::stdout().flush();
-        }
+        // TODO: remove whole to_stdout option
+        //if self.options.to_stdout {
+        //    let _ = std::io::stdout().flush();
+        //}
         self.file.flush()
     }
 }
-- 
2.39.5



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied:  [PATCH] log: ignore to_stdout parameter
  2024-11-27 11:46 [pbs-devel] [PATCH] log: ignore to_stdout parameter Gabriel Goller
@ 2024-11-27 12:33 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2024-11-27 12:33 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Gabriel Goller

Am 27.11.24 um 12:46 schrieb Gabriel Goller:
> This parameter causes the FileLogger to duplicate the log output to
> stdout. This causes duplicate output on proxmox-backup-manager because
> this is now handled by tracing. This should be removed completely in the
> future.
> In the worst case this will only result in missing log lines on stdout
> (which is visible only on proxmox-backup-manager/client invocations
> anyway).
> 
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  proxmox-log/src/file_logger.rs | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
>

applied, with a doc-comment added to the respective struct member so that it's
less likely that this will get new users, thanks!


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-27 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 11:46 [pbs-devel] [PATCH] log: ignore to_stdout parameter Gabriel Goller
2024-11-27 12:33 ` [pbs-devel] applied: " Thomas Lamprecht

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