summaryrefslogtreecommitdiff
path: root/src/log_level.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-02-03 09:04:47 +1300
committerBen Bridle <ben@derelict.engineering>2025-02-03 09:20:04 +1300
commitd29420c886d77095c99761f6deb71081f7bc8dcb (patch)
tree331fac599cc723d72e3bfd2c8fd95b23d33896bd /src/log_level.rs
downloadlog-d29420c886d77095c99761f6deb71081f7bc8dcb.zip
Initial commit
Diffstat (limited to 'src/log_level.rs')
-rw-r--r--src/log_level.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/log_level.rs b/src/log_level.rs
new file mode 100644
index 0000000..6c84cb0
--- /dev/null
+++ b/src/log_level.rs
@@ -0,0 +1,37 @@
+
+use std::cmp::Ordering;
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum LogLevel {
+ /// Verbose record of decisions and operations.
+ Info,
+ /// Report recoverable issues.
+ Warn,
+ /// Report unrecoverable errors and quit.
+ Error,
+}
+
+impl PartialOrd for LogLevel {
+ fn partial_cmp(&self, other: &LogLevel) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for LogLevel {
+ fn cmp(&self, other: &LogLevel) -> Ordering {
+ use LogLevel::*;
+ match (self, other) {
+ (Info , Info ) => Ordering::Equal,
+ (Info , Warn ) => Ordering::Less,
+ (Info , Error) => Ordering::Less,
+
+ (Warn , Info ) => Ordering::Greater,
+ (Warn , Warn ) => Ordering::Equal,
+ (Warn , Error) => Ordering::Less,
+
+ (Error , Info ) => Ordering::Greater,
+ (Error , Warn ) => Ordering::Greater,
+ (Error , Error) => Ordering::Equal,
+ }
+ }
+}