]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tools file logger: fix example and comments
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Oct 2020 09:16:29 +0000 (11:16 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Oct 2020 09:16:29 +0000 (11:16 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/tools/file_logger.rs

index 2f406c0d16561b614d94f4afd5a9d6f80a7bdd48..e0735b98fb0ab3bd31456189e9de351588ededb4 100644 (file)
@@ -1,7 +1,7 @@
 use anyhow::Error;
 use std::io::Write;
 
-/// Log messages with timestamps into files
+/// Log messages with optional automatically added timestamps into files
 ///
 /// Logs messages to file, and optionally to standard output.
 ///
@@ -10,18 +10,25 @@ use std::io::Write;
 /// ```
 /// #[macro_use] extern crate proxmox_backup;
 /// # use anyhow::{bail, format_err, Error};
-/// use proxmox_backup::tools::FileLogger;
+/// use proxmox_backup::tools::{FileLogger, FileLogOptions};
 ///
 /// # std::fs::remove_file("test.log");
-/// let mut log = FileLogger::new("test.log", true).unwrap();
+/// let options = FileLogOptions {
+///     to_stdout: true,
+///     exclusive: true,
+///     ..Default::default()
+/// };
+/// let mut log = FileLogger::new("test.log", options).unwrap();
 /// flog!(log, "A simple log: {}", "Hello!");
 /// ```
 
 #[derive(Debug, Default)]
 /// Options to control the behavior of a ['FileLogger'] instance
 pub struct FileLogOptions {
-    /// Open underlying log file in append mode, useful when multiple concurrent
-    /// writers log to the same file. For example, an HTTP access log.
+    /// Open underlying log file in append mode, useful when multiple concurrent processes
+    /// want to log to the same file (e.g., HTTP access log). Note that it is only atomic
+    /// for writes smaller than the PIPE_BUF (4k on Linux).
+    /// Inside the same process you may need to still use an mutex, for shared access.
     pub append: bool,
     /// Open underlying log file as readable
     pub read: bool,