aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/admin/log.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-10 15:28:36 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-10 15:28:36 +0200
commit05d11426a8e60fa060733eb8ae7843bc2ae9725c (patch)
tree57cfad9cedf1eb50de193f1657b42234745c044e /server/src/routes/ui/admin/log.rs
parentc0365c8c64f403fd9ee75c0db1a9ed6134633e8f (diff)
downloadjellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar
jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.bz2
jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.zst
apply many clippy issue
Diffstat (limited to 'server/src/routes/ui/admin/log.rs')
-rw-r--r--server/src/routes/ui/admin/log.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/server/src/routes/ui/admin/log.rs b/server/src/routes/ui/admin/log.rs
index 5b81a52..884ad7a 100644
--- a/server/src/routes/ui/admin/log.rs
+++ b/server/src/routes/ui/admin/log.rs
@@ -22,7 +22,7 @@ use std::{
const MAX_LOG_LEN: usize = 4096;
-static LOGGER: LazyLock<Log> = LazyLock::new(Log::new);
+static LOGGER: LazyLock<Log> = LazyLock::new(Log::default);
pub fn enable_logging() {
log::set_logger(&*LOGGER).unwrap();
@@ -63,9 +63,8 @@ pub fn r_admin_log<'a>(_session: AdminSession, warnonly: bool) -> MyResult<DynLa
..Default::default()
})
}
-
-impl Log {
- pub fn new() -> Self {
+impl Default for Log {
+ fn default() -> Self {
Self {
inner: env_logger::builder()
.filter_level(log::LevelFilter::Warn)
@@ -74,6 +73,8 @@ impl Log {
log: Default::default(),
}
}
+}
+impl Log {
fn should_log(&self, metadata: &log::Metadata) -> bool {
let level = metadata.level();
level
@@ -152,18 +153,11 @@ fn format_level(level: Level) -> impl markup::Render {
markup::new! { span[style=format!("color:{c}")] {@s} }
}
+#[derive(Default)]
pub struct HtmlOut {
s: String,
color: bool,
}
-impl Default for HtmlOut {
- fn default() -> Self {
- Self {
- color: false,
- s: String::new(),
- }
- }
-}
impl HtmlOut {
pub fn set_color(&mut self, [r, g, b]: [u8; 3]) {
self.reset_color();
@@ -184,16 +178,12 @@ impl vte::Perform for HtmlOut {
x => write!(self.s, "&#{};", x as u32).unwrap(),
}
}
-
fn execute(&mut self, _byte: u8) {}
fn hook(&mut self, _params: &vte::Params, _i: &[u8], _ignore: bool, _a: char) {}
fn put(&mut self, _byte: u8) {}
fn unhook(&mut self) {}
fn osc_dispatch(&mut self, _params: &[&[u8]], _bell_terminated: bool) {}
- fn esc_dispatch(&mut self, _intermediates: &[u8], _ignore: bool, _byte: u8) {
- // self.s += &format!(" {:?} ", (_intermediates, _byte))
- }
-
+ fn esc_dispatch(&mut self, _intermediates: &[u8], _ignore: bool, _byte: u8) {}
fn csi_dispatch(
&mut self,
params: &vte::Params,
@@ -202,9 +192,9 @@ impl vte::Perform for HtmlOut {
action: char,
) {
let mut k = params.iter();
- // self.s += &format!(" {:?} ", (params, action));
+ #[allow(clippy::single_match)]
match action {
- 'm' => match k.next().unwrap_or(&[0]).get(0).unwrap_or(&0) {
+ 'm' => match k.next().unwrap_or(&[0]).first().unwrap_or(&0) {
c @ (30..=37 | 40..=47) => {
let c = if *c >= 40 { *c - 10 } else { *c };
self.set_color(match c {