@smbcloud / cli / commits / 1f5ef8b

Print debug only in debug

Seto Elkahfi committed Feb 28, 2023 at 22:12 UTC 1f5ef8b637707ba5f2114fddfb3612788c0ba5cd
1 file changed +17 -2
src/login/process.rs
+17 -2
@@ -44,6 +44,21 @@ struct Data {
44 created_at: String,
45 }
46
47 +macro_rules! debug {
48 + ($($e:expr),+) => {
49 + {
50 + #[cfg(debug_assertions)]
51 + {
52 + dbg!($($e),+)
53 + }
54 + #[cfg(not(debug_assertions))]
55 + {
56 + ($($e),+)
57 + }
58 + }
59 + };
60 +}
61 +
62 pub async fn process_login(args: LoginArgs) -> Result<()> {
63 let login_params = LoginParams {
64 user: User {
@@ -63,10 +78,10 @@ pub async fn process_login(args: LoginArgs) -> Result<()> {
78 let headers = response.headers();
79 match headers.get("Authorization") {
80 Some(token) => {
66 - println!("Token: {:?}", token.to_str()?);
81 + debug!(token.to_str()?);
82 match home::home_dir() {
83 Some(path) => {
69 - print!("Home directory: {:?}", path);
84 + debug!(path.to_str().unwrap());
85 create_dir_all(path.join(".smb"))?;
86 let mut file = OpenOptions::new()
87 .create(true)