Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
fix: remove log module
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Sep 10, 2024
1 parent fac5435 commit c72d09c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use byteorder::ReadBytesExt;
use byteorder::WriteBytesExt;

use crate::io::IOEndianness;
use crate::log::loge;
use crate::log_macros::log_error;
use crate::result::IntoLevelIOErr;
use crate::result::IntoLevelInitErr;
use crate::result::LevelInitError;
Expand Down Expand Up @@ -104,8 +104,8 @@ pub(crate) fn init_sparse_file(
match file.read_u64::<IOEndianness>() {
Ok(magic_f) => {
if magic_f != magic {
loge(&format!("magic number mismatch: {} != {}", magic_f, magic));
loge(&format!("removing {}", path.display()));
log_error!("magic number mismatch: {} != {}", magic_f, magic);
log_error!("removing {}", path.display());
file.set_len(0)
.into_lvl_io_e_msg("couldn't truncate file".to_string())?;
write_magic_file(&mut file, Some(magic))?;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ pub use level_hash::*;
pub(crate) mod fs;
pub(crate) mod io;
pub(crate) mod level_io;

#[allow(unused_macros, unused_imports)]
pub(crate) mod log_macros;
pub(crate) mod meta;
pub(crate) mod reprs;
pub(crate) mod size;
pub(crate) mod types;

pub mod log;
pub mod result;
pub mod util;

Expand Down
24 changes: 0 additions & 24 deletions src/log.rs

This file was deleted.

59 changes: 59 additions & 0 deletions src/log_macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/

macro_rules! log_trace {
($($arg:tt)*) => {
crate::log_macros::do_log!("TRACE", $($arg)*)
};
}

macro_rules! log_debug {
($($arg:tt)*) => {
crate::log_macros::do_log!("DEBUG", $($arg)*)
};
}

macro_rules! log_info {
($($arg:tt)*) => {
crate::log_macros::do_log!("INFO", $($arg)*)
};
}

macro_rules! log_warn {
($($arg:tt)*) => {
crate::log_macros::do_log!("WARN", $($arg)*)
};
}

macro_rules! log_error {
($($arg:tt)*) => {
crate::log_macros::do_log!("ERROR", $($arg)*)
};
}

macro_rules! do_log {
($level:literal, $($arg:tt)*) => {
println!("[{}] [{}:{}:{}] {}", $level, module_path!(), file!(), line!(), format_args!($($arg)*))
};
}

pub(crate) use do_log;
pub(crate) use log_debug;
pub(crate) use log_error;
pub(crate) use log_info;
pub(crate) use log_trace;
pub(crate) use log_warn;

0 comments on commit c72d09c

Please sign in to comment.