Skip to content

Commit

Permalink
ref: rename tracing package to log
Browse files Browse the repository at this point in the history
conflicts with running cargo check and test
  • Loading branch information
kkharji committed Jun 19, 2022
1 parent 860b37c commit c28a0ef
Show file tree
Hide file tree
Showing 26 changed files with 107 additions and 108 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]

# Internal
tracing = { path = "./../tracing/" }
log = { path = "./../log/" }
xbase-proto = { path = "./../proto/" }

# Error Handling
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RequestHandler for BuildRequest {
#[async_trait]
impl Watchable for BuildRequest {
async fn trigger(&self, state: &MutexGuard<State>, _event: &Event) -> Result<()> {
tracing::info!("Building {}", self.client.abbrev_root());
log::info!("Building {}", self.client.abbrev_root());
let is_once = self.ops.is_once();
let (root, config) = (&self.client.root, &self.settings);
// let args = state.projects.get(root)?.build_args(&config, &None)?;
Expand All @@ -52,7 +52,7 @@ impl Watchable for BuildRequest {
config.target
));

tracing::trace!("building with [{}]", args.join(" "));
log::trace!("building with [{}]", args.join(" "));
let xclogger = XCLogger::new(&root, args)?;
let success = logger.consume_build_logs(xclogger, false, is_once).await?;

Expand Down
2 changes: 1 addition & 1 deletion daemon/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn ensure_server_config(root: &PathBuf) -> Result<()> {
return Ok(());
}

tracing::info!("Creating {:?}", path);
log::info!("Creating {:?}", path);

let mut file = tokio::fs::File::create(path).await?;
file.write_all(
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl RequestHandler for DropRequest {
let ref mut state = state.lock().await;

if state.clients.contains_key(&client.pid) {
tracing::info!("Drop({}: {})", client.pid, client.abbrev_root());
log::info!("Drop({}: {})", client.pid, client.abbrev_root());
// NOTE: Should only be Some if no more client depend on it
if let Some(_) = state.projects.remove(&client).await? {
// NOTE: Remove project watchers
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Error {
#[error("[Error] (Compile): {0}")]
Compile(#[from] CompileError),
#[error("{0}")]
Tracing(#[from] tracing::TracingError),
Tracing(#[from] log::TracingError),
#[error("[Error] (Conversion) {0}")]
Conversion(#[from] ConversionError),
#[error("[Error] (Lookup) {0} with {0} doesn't exist")]
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait RequestHandler {
where
Self: Sized + std::fmt::Debug,
{
tracing::error!("Not Implemented! {:#?}", self);
log::error!("Not Implemented! {:#?}", self);
Ok(())
}
}
14 changes: 7 additions & 7 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use tap::Pipe;
use tokio::fs::{metadata, read_to_string, remove_file, write};
use tokio::io::AsyncReadExt;
use tokio::net::UnixListener;
use tracing::Level;
use log::Level;
use xbase_daemon::util::pid;
use xbase_daemon::Result;
use xbase_daemon::{constants::*, RequestHandler};
Expand All @@ -14,16 +14,16 @@ async fn main() -> Result<()> {

let listener = UnixListener::bind(DAEMON_SOCKET_PATH).unwrap();

tracing::setup("/tmp", "xbase-daemon.log", Level::TRACE, true)?;
log::setup("/tmp", "xbase-daemon.log", Level::TRACE, true)?;

tracing::info!("Started");
log::info!("Started");
loop {
if let Ok((mut s, _)) = listener.accept().await {
tokio::spawn(async move {
let msg = {
let mut msg = String::default();
if let Err(e) = s.read_to_string(&mut msg).await {
return tracing::error!("[Read Error]: {:?}", e);
return log::error!("[Read Error]: {:?}", e);
};
msg
};
Expand All @@ -34,13 +34,13 @@ async fn main() -> Result<()> {

let req = match Request::read(msg.clone()) {
Err(e) => {
return tracing::error!("[Parse Error]: {:?} message: {msg}", e);
return log::error!("[Parse Error]: {:?} message: {msg}", e);
}
Ok(req) => req,
};

if let Err(e) = handle(req).await {
return tracing::error!("[Failure]: Cause: ({:?})", e);
return log::error!("[Failure]: Cause: ({:?})", e);
};

let state = DAEMON_STATE.clone();
Expand All @@ -50,7 +50,7 @@ async fn main() -> Result<()> {
// update_watchers(state.clone()).await;
});
} else {
tracing::error!("Fail to accept a connection")
log::error!("Fail to accept a connection")
};
}
}
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/nvim/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a> Logger<'a> {

// TODO(logger): always show current new logs in middle of the window
pub async fn append(&mut self, msg: String) -> Result<()> {
tracing::trace!("{msg}");
log::trace!("{msg}");
let win_info = self.win().await;
let mut c = self.get_line_count().await?;

Expand Down Expand Up @@ -135,7 +135,7 @@ impl<'a> Logger<'a> {
return Ok(win);
}

tracing::info!("Openning a new window");
log::info!("Openning a new window");

if self.open_cmd.is_none() {
let v = self.nvim.get_window_direction(None).await?;
Expand Down Expand Up @@ -222,7 +222,7 @@ impl NvimClient {
{
Ok(open_command) => open_command,
Err(e) => {
tracing::error!("Unable to convert value to string {e}");
log::error!("Unable to convert value to string {e}");
BufferDirection::Horizontal.to_nvim_command(*bufnr)
}
}
Expand Down
16 changes: 8 additions & 8 deletions daemon/src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Project {
project.generator = ProjectGenerator::new(root);

project.inner = if root.join("Package.swift").exists() {
tracing::debug!("[Project] Kind: \"Swift\"",);
log::debug!("[Project] Kind: \"Swift\"",);
// TODO(project): Get swift project name
project.name = "UnknownSwiftProject".into();
ProjectInner::Swift
Expand All @@ -72,10 +72,10 @@ impl Project {
project.name = xcodeproj.name().to_owned();
project.targets = xcodeproj.targets_platform();

tracing::debug!("[New Project] name: {:?}", project.name);
tracing::debug!("[New Project] Kind: \"XCodeProject\"");
tracing::debug!("[New Project] Generator: \"{:?}\"", project.generator);
tracing::debug!("[New Project] targets: {:?}", project.targets);
log::debug!("[New Project] name: {:?}", project.name);
log::debug!("[New Project] Kind: \"XCodeProject\"");
log::debug!("[New Project] Generator: \"{:?}\"", project.generator);
log::debug!("[New Project] targets: {:?}", project.targets);

ProjectInner::XCodeProject(xcodeproj)
};
Expand All @@ -102,7 +102,7 @@ impl Project {

self.root = root;
self.clients = clients;
tracing::info!("[Projects] update({:?})", self.name);
log::info!("[Projects] update({:?})", self.name);

Ok(())
}
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Project {
pub async fn generate_compile_commands(&self) -> Result<()> {
use xclog::{XCCompilationDatabase, XCCompileCommand};

tracing::info!("Generating compile commands ... ");
log::info!("Generating compile commands ... ");
let mut compile_commands: Vec<XCCompileCommand> = vec![];
let cache_root = get_build_cache_dir(&self.root)?;
// Because xcodebuild clean can't remove it
Expand All @@ -161,7 +161,7 @@ impl Project {
.into_iter()
.for_each(|cmd| compile_commands.push(cmd));

tracing::info!("Compile Commands Generated");
log::info!("Compile Commands Generated");

let json = serde_json::to_vec_pretty(&compile_commands)?;
tokio::fs::write(self.root.join(".compile"), &json).await?;
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RequestHandler for RunRequest {
where
Self: Sized + std::fmt::Debug,
{
tracing::info!("⚙️ Running: {}", self.settings.to_string());
log::info!("⚙️ Running: {}", self.settings.to_string());

let ref key = self.to_string();
let state = DAEMON_STATE.clone();
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/run/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl RunServiceHandler {
let ref mut logger = match state.clients.get(&client.pid) {
Ok(nvim) => nvim.logger(),
Err(_) => {
tracing::info!("Nvim Instance closed, closing runner ..");
log::info!("Nvim Instance closed, closing runner ..");
state.watcher.get_mut(&client.root)?.listeners.remove(&key);
kill_send.send(()).await.ok();
break;
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/run/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl RunService {
#[async_trait::async_trait]
impl Watchable for RunService {
async fn trigger(&self, state: &MutexGuard<State>, _event: &Event) -> Result<()> {
tracing::info!("Running {}", self.client.abbrev_root());
log::info!("Running {}", self.client.abbrev_root());

let (root, config) = (&self.client.root, &self.medium.settings());
let mut handler = self.handler.clone().lock_owned().await;
Expand Down
Loading

0 comments on commit c28a0ef

Please sign in to comment.