Skip to main content

chrome_for_testing/
chromedriver.rs

1use std::fmt::{Display, Formatter};
2
3/// The chromedriver binary can be passed one of these log-levels.
4///
5/// Defaults to `Info`. This is enough to get the "started on port ..." line on stdout.
6///
7/// For example, if launching chromedriver with std/tokio `Process`, do this:
8/// ```no_run
9/// let mut command = std::process::Command::new("chromedriver");
10/// let loglevel = chrome_for_testing::chromedriver::LogLevel::All;
11/// command.arg(format!("--log-level={loglevel}"));
12/// ```
13#[derive(Default, Debug, PartialEq, Eq)]
14pub enum LogLevel {
15    /// Log all messages (most verbose).
16    All,
17
18    /// Log debug messages and above.
19    Debug,
20
21    /// Log info messages and above (default level).
22    #[default]
23    Info,
24
25    /// Log warning messages and above.
26    Warning,
27
28    /// Log only severe/error messages.
29    Severe,
30
31    /// Disable all logging.
32    Off,
33}
34
35impl Display for LogLevel {
36    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
37        f.write_str(match self {
38            LogLevel::All => "ALL",
39            LogLevel::Debug => "DEBUG",
40            LogLevel::Info => "INFO",
41            LogLevel::Warning => "WARNING",
42            LogLevel::Severe => "SEVERE",
43            LogLevel::Off => "OFF",
44        })
45    }
46}