mirror of https://github.com/xvxx/phetch
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
662 B
Rust
30 lines
662 B
Rust
5 years ago
|
#[allow(unused_macros)]
|
||
|
macro_rules! log {
|
||
|
($e:expr) => {{
|
||
|
if cfg!(debug_assertions) {
|
||
|
if let Ok(mut file) = std::fs::OpenOptions::new()
|
||
|
.append(true)
|
||
|
.create(true)
|
||
|
.open("phetch.log")
|
||
|
{
|
||
|
file.write($e.as_ref());
|
||
|
file.write(b"\n");
|
||
|
}
|
||
|
}
|
||
|
}};
|
||
|
($e:expr, $($y:expr),*) => {
|
||
|
if cfg!(debug_assertions) {
|
||
|
log!(format!($e, $($y),*));
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
macro_rules! error {
|
||
|
($e:expr) => {
|
||
|
std::io::Error::new(std::io::ErrorKind::Other, $e)
|
||
|
};
|
||
|
($e:expr, $($y:expr),*) => {
|
||
|
error!(format!($e, $($y),*));
|
||
|
};
|
||
|
}
|