Skip to content

Commit

Permalink
enh(logger): output readability and traceability
Browse files Browse the repository at this point in the history
  • Loading branch information
kkharji committed May 26, 2022
1 parent f32fd6b commit c545b73
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ tokio = { version = "1.17.0", features = ["full"], optional = tr
tokio-util = { version = "0.7.1", features = ["codec"], optional = true }
async-trait = { version = "0.1.52", optional = true }
async-stream = { version = "0.3.3", optional = true }
process-stream = { version = "0.2.2", optional = true }
process-stream = { version = "0.2.*", optional = true }
# Logging Feature
tracing = { version = "0.1.32", optional = true }
tracing-subscriber = { version = "0.3.9", features = ["env-filter"], optional = true}
Expand All @@ -88,8 +88,8 @@ lazy_static = { version = "1.4.0", optional = true }
shell-words = { version = "1.1.0", optional = true }
# Other
mlua = { version = "0.7.4", features = ["lua51", "vendored"], optional = true }
bsp-server = { version = "0.1.3", optional = true }
xcodebuild = { version = "0.1.5", optional = true, features = ["tracing"] }
bsp-server = { version = "0.1.*", optional = true }
xcodebuild = { version = "0.1.*", optional = true, features = ["tracing"] }

# Proc feature: processes, processors, disks, components and networks (sysinfo = "0.23.5")
libproc = { version = "0.12.0", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion src/nvim/logger.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{NvimClient, NvimConnection, NvimWindow};
use crate::nvim::BufferDirection;
use crate::Result;
use crate::{nvim::BufferDirection, util::fmt};
use nvim_rs::{Buffer, Window};

pub struct Logger<'a> {
Expand Down Expand Up @@ -117,6 +117,7 @@ impl<'a> Logger<'a> {
self.nvim
.exec("let g:xbase_watch_build_status='success'", false)
.await?;
self.append(fmt::separator()).await?;
} else {
self.nvim
.exec("let g:xbase_watch_build_status='failure'", false)
Expand Down
2 changes: 1 addition & 1 deletion src/run/handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(dead_code)]
use crate::{client::Client, constants::DAEMON_STATE, Result};
use crate::{client::Client, constants::DAEMON_STATE, util::fmt, Result};
use process_stream::{Process, StreamExt};
use tokio::task::JoinHandle;

Expand Down
4 changes: 3 additions & 1 deletion src/run/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl RunService {
logger.set_running().await?;
}

logger.set_title(format!("Run:{target}"));
logger.set_title(format!("Build:{target}"));
logger.set_direction(&req.direction);

let build_settings = build_settings(root, &build_args).await?;
Expand All @@ -52,6 +52,8 @@ impl RunService {
return Err(Error::Build(msg));
}

logger.set_title(format!("Run:{target}"));

let medium = RunMedium::from_device_or_settings(device, build_settings, req.config)?;
let process = medium.run(logger).await?;
let handler = RunServiceHandler::new(target, req.client.clone(), process, key.clone())?;
Expand Down
8 changes: 4 additions & 4 deletions src/run/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ impl Simulator {

impl Simulator {
fn booting_msg(&self) -> String {
format!("[{}] Booting {}", self.config.target, self.device.name)
format!("Booting {}", self.device.name)
}

fn installing_msg(&self) -> String {
format!("[{}] Installing {}", self.config.target, self.app_id())
format!("Installing {}", self.app_id())
}

fn launching_msg(&self) -> String {
format!("[{}] Launching {}", self.config.target, self.app_id())
format!("Launching {}", self.app_id())
}

fn connected_msg(&self) -> String {
format!("[{}] Connected", self.config.target)
format!("Connected")
}
}
10 changes: 3 additions & 7 deletions src/xcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tap::Pipe;
use xcodebuild::{parser, runner::spawn};

#[cfg(feature = "daemon")]
use {crate::util::fmt, std::fmt::Debug};
use std::fmt::Debug;

#[cfg(feature = "daemon")]
pub async fn stream_build<'a, P: 'a>(
Expand All @@ -25,12 +25,8 @@ where
use xcodebuild::parser::Step::*;
while let Some(step) = stream.next().await {
let line = match step {
Exit(v) => {
if v == 0 {
fmt::separator()
} else {
"[Error] Build Failed".into()
}
Exit(v) if v != 0 => {
"[Error] Build Failed".into()
}
BuildSucceed | CleanSucceed | TestSucceed | TestFailed | BuildFailed => {
continue;
Expand Down
16 changes: 8 additions & 8 deletions syntax/xcodebuildlog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ set cpo&vim
syn match XbaseOperations "\(Executing\|Compiling\|Generating\|Processing\|Emitting\|Compiling\|Copying\|Validating\|Signing\|Linking\|RegisterLaunchServices\|\Installing\|Booting\|Launching\)"
syn match XbaseEntitlement "Entitlement"
syn region XbaseScope display oneline start='^\[' end='\]'
syn match XbaseLogError "^\(\[Error\]\)"
syn match XbaseLogWarn "^\(\[Warning\]\)"
syn match XbaseLogSuccess "^\(\[Succeed\]\)"
syn match XbaseLogError "\(\[Error\]\)"
syn match XbaseLogWarn "\(\[Warning\]\)"
syn match XbaseLogSuccess "\(\[Succeed\]\)"
syn match XbaseLogConnected "\(Connected\)"
syn match XbaseLogDone "^\(\[Done\]\)"
syn match XbaseLogPackage "^\(\[Package\]\)"
syn match XbaseLogOutput "^\(\[Output\]\)"
syn match XbaseLogOutput "^\(\[Exit\]\)"
syn match XbaseRunning "^\(\[Running\]\)"
syn match XbaseLogDone "\(\[Done\]\)"
syn match XbaseLogPackage "\(\[Package\]\)"
syn match XbaseLogOutput "\(\[Output\]\)"
syn match XbaseLogOutput "\(\[Exit\]\)"
syn match XbaseRunning "\(\[Running\]\)"
syn match XbaseTarget "`\(\w.*\)`"
syn match XbaseFilePath "`\(\/.*\)`"
syn region XbaseSep display oneline start='-' end='-$'
Expand Down

0 comments on commit c545b73

Please sign in to comment.