From 27634423d90df538070e052ba4cbd8b9811fae51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Palenica?= Date: Sat, 17 Jul 2021 23:50:24 -0700 Subject: [PATCH] Minor fixes --- src/main.rs | 2 -- zellij-client/src/lib.rs | 1 + zellij-server/src/lib.rs | 2 +- zellij-server/src/logging_pipe.rs | 18 ++++++------------ zellij-utils/src/logging.rs | 4 +--- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1fa3343b3..612e130ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,6 @@ mod sessions; mod tests; use crate::install::populate_data_dir; -use log::info; use sessions::{assert_session, assert_session_ne, get_active_session, list_sessions}; use std::convert::TryFrom; use std::process; @@ -21,7 +20,6 @@ use zellij_utils::{ pub fn main() { configure_logger(); - info!("Starting Zellij!"); let opts = CliArgs::from_args(); if let Some(Command::Sessions(Sessions::ListSessions)) = opts.command { diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index d456103aa..d9dda42ca 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -89,6 +89,7 @@ pub fn start_client( info: ClientInfo, layout: Option, ) { + info!("Starting Zellij client!"); let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}12l\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l"; let take_snapshot = "\u{1b}[?1049h"; let bracketed_paste = "\u{1b}[?2004h"; diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index b8cbbc5dc..690304bb5 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -116,7 +116,7 @@ pub(crate) enum SessionState { } pub fn start_server(os_input: Box, socket_path: PathBuf) { - info!("starts server"); + info!("Starting Zellij server!"); daemonize::Daemonize::new() .working_directory(std::env::current_dir().unwrap()) .umask(0o077) diff --git a/zellij-server/src/logging_pipe.rs b/zellij-server/src/logging_pipe.rs index eecfa2d3c..a2658cf9b 100644 --- a/zellij-server/src/logging_pipe.rs +++ b/zellij-server/src/logging_pipe.rs @@ -3,7 +3,7 @@ use std::{ io::{Read, Seek, Write}, }; -use log::{debug, error, info}; +use log::{debug, error}; use wasmer_wasi::{WasiFile, WasiFsError}; use zellij_utils::serde; @@ -22,13 +22,6 @@ pub struct LoggingPipe { impl LoggingPipe { pub fn new(plugin_name: &str, plugin_id: u32) -> LoggingPipe { - info!( - "|{:<25.25}| {} [{:<10.15}] Creating decorating pipe for plugin: {}!", - plugin_name, - Local::now().format("%Y-%m-%d %H:%M:%S.%3f"), - format!("id: {}", plugin_id), - plugin_name - ); LoggingPipe { buffer: VecDeque::new(), plugin_name: String::from(plugin_name), @@ -49,11 +42,12 @@ impl LoggingPipe { impl Read for LoggingPipe { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + // NOTE: should we do this? I think if anyone were to chain LoggingPipe and read from it, + // they would see very weird behavior because we drain self.buffer in `flush`. Also, logs would be screwed up. + // Consider removing this code. let amt = std::cmp::min(buf.len(), self.buffer.len()); - for (i, byte) in self.buffer.drain(..amt).enumerate() { - buf[i] = byte; - } - Ok(amt) + let data: Vec<_> = self.buffer.drain(..amt).collect(); + buf.as_mut().write(&data) } } diff --git a/zellij-utils/src/logging.rs b/zellij-utils/src/logging.rs index d7f35344d..7e57eebda 100644 --- a/zellij-utils/src/logging.rs +++ b/zellij-utils/src/logging.rs @@ -7,7 +7,7 @@ use std::{ path::{Path, PathBuf}, }; -use log::{info, LevelFilter}; +use log::LevelFilter; use log4rs::append::file::FileAppender; use log4rs::config::{Appender, Config, Logger, Root}; @@ -59,8 +59,6 @@ pub fn configure_logger() { .unwrap(); let _ = log4rs::init_config(config).unwrap(); - - info!("Zellij logger initialized"); } pub fn atomic_create_file(file_name: &Path) -> io::Result<()> {