use log instead of print

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2023-09-01 15:03:11 +02:00
parent 625420c5f6
commit 0ae6ce5e88
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
10 changed files with 54 additions and 19 deletions

View file

@ -5,6 +5,7 @@ use crate::{
MapList, MethodHandleItem, MethodIdItem, ProtoIdItem, Result, Serializable, StringDataItem,
StringIdItem, TypeIdItem,
};
use log::{error, info, warn};
use std::io::{Cursor, Seek, SeekFrom};
pub struct DexFileReader<'a> {
@ -144,32 +145,32 @@ impl<'a> DexFileReader<'a> {
fn sanity_check(&self) -> Result<()> {
if self.header.magic.version != [0x30, 0x33, 0x39] {
println!(
warn!(
"DEX 039 is the only verion currently supported, found {}",
std::str::from_utf8(self.header.magic.version.as_slice())
.unwrap_or(&format!("{:x?}", self.header.magic.version))
); // TODO: use proper logging
);
}
// TODO: check checksum
// TODO: check signature
if self.header.file_size as usize != self.data.len() {
println!(
info!(
"Unexpected file size found: {}, expected {}",
self.header.file_size,
self.data.len()
); // TODO: use proper logging
);
}
if self.header.header_size != 0x70 {
println!(
info!(
"Unexpected header size found: 0x{:x}",
self.header.header_size
); // TODO: use proper logging
);
}
if self.header.endian_tag != EndianConstant::EndianConstant {
println!("Wrong endian_tag found: {:x?}", self.header.endian_tag); // TODO: use proper logging
warn!("Wrong endian_tag found: {:x?}", self.header.endian_tag);
}
if self.header.link_off != 0 || self.header.link_size != 0 {
println!("Found non empty link section"); // TODO: use proper logging
info!("Found non empty link section, the section will be ignored");
}
for item in &self.map_list.list {
match item.type_ {
@ -261,8 +262,7 @@ impl<'a> DexFileReader<'a> {
MapItemType::HiddenapiClassDataItem => todo!(),
*/
MapItemType::UnkownType(ty) => {
println!("Unknown Type found in map_list: 0x{ty:04x}"); // TODO: use proper
// loggin
info!("Unknown Type found in map_list: 0x{ty:04x}, it will be ignored");
}
_ => (),
}
@ -273,8 +273,7 @@ impl<'a> DexFileReader<'a> {
let mut duplicate = false;
for (ty, val) in occurences {
if val > 1 {
println!("Found multiple {} occurence of {:?} in map_list", val, ty);
// TODO: use proper loggin
error!("Found multiple {} occurence of {:?} in map_list", val, ty);
duplicate = true;
}
}