Skip to content

Commit ba2146f

Browse files
authored
cycles-sync: Fix logging (#5)
1 parent 44861f0 commit ba2146f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

utils/cycles-sync/src/main.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use clap::Parser;
1818
use cosmwasm_std::HexBinary;
1919
use serde::{Deserialize, Serialize};
2020
use serde_json::json;
21-
use tracing::{info, Level};
21+
use tracing::{debug, Level};
2222
use uuid::Uuid;
2323

2424
use crate::{
@@ -60,9 +60,10 @@ async fn main() -> Result<(), DynError> {
6060
.with_max_level(if cli.verbose {
6161
Level::DEBUG
6262
} else {
63-
Level::INFO
63+
Level::ERROR
6464
})
6565
.with_level(true)
66+
.with_writer(std::io::stderr)
6667
.init();
6768

6869
match cli.command {
@@ -115,7 +116,7 @@ async fn sync_setoffs(cli: Cli) -> Result<(), DynError> {
115116
})
116117
.collect();
117118

118-
info!("setoffs: {setoffs:?}");
119+
debug!("setoffs: {setoffs:?}");
119120

120121
// send to Obligato
121122
let client = HttpClient::new(OBLIGATO_URL.parse().unwrap());
@@ -136,13 +137,13 @@ async fn sync_obligations(cli: Cli, epoch_pk: &str) -> Result<(), DynError> {
136137

137138
add_default_acceptances(&mut intents, bank_id);
138139

139-
info!("intents: {intents:?}");
140+
debug!("intents: {intents:?}");
140141

141142
let intents_enc = {
142143
let epoch_pk = VerifyingKey::from_sec1_bytes(&hex::decode(epoch_pk).unwrap()).unwrap();
143144
encrypt_intents(intents, keys, &epoch_pk, cli.obligation_user_map_file)
144145
};
145-
info!("Encrypted {} intents", intents_enc.len());
146+
debug!("Encrypted {} intents", intents_enc.len());
146147

147148
let msg = create_wasm_msg(intents_enc);
148149
let wasmd_client = CliWasmdClient::new(cli.node);

utils/cycles-sync/src/obligato_client/http.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use async_trait::async_trait;
22
use reqwest::Url;
33
use serde::{Deserialize, Serialize};
44
use serde_json::json;
5+
use tracing::log::debug;
56

67
use crate::{
78
obligato_client::Client,
@@ -54,7 +55,7 @@ impl Client for HttpClient {
5455
.json(&setoffs)
5556
.send()
5657
.await?;
57-
println!("{}", response.text().await.unwrap());
58+
debug!("{}", response.text().await.unwrap());
5859

5960
Ok(())
6061
}

utils/cycles-sync/src/wasmd_client.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{error::Error, process::Command};
33
use cosmrs::{tendermint::chain::Id, AccountId};
44
use reqwest::Url;
55
use serde::{Deserialize, Serialize};
6+
use tracing::debug;
67

78
pub trait WasmdClient {
89
type Address: AsRef<str>;
@@ -75,7 +76,7 @@ impl WasmdClient for CliWasmdClient {
7576
.args(["--output", "json"]);
7677

7778
let output = command.output()?;
78-
println!("{:?} => {:?}", command, output);
79+
debug!("{:?} => {:?}", command, output);
7980

8081
let query_result = R::from_vec(output.stdout);
8182
Ok(query_result)
@@ -97,10 +98,15 @@ impl WasmdClient for CliWasmdClient {
9798
.args(["--chain-id", chain_id.as_ref()])
9899
.args(["--gas", &gas.to_string()])
99100
.args(["--from", sender.as_ref()])
101+
.args(["--output", "json"])
100102
.arg("-y");
101103

102104
let output = command.output()?;
103-
println!("{:?} => {:?}", command, output);
105+
debug!("{:?} => {:?}", command, output);
106+
107+
if output.status.success() {
108+
println!("{}", String::from_utf8(output.stdout).unwrap());
109+
}
104110

105111
Ok(())
106112
}

0 commit comments

Comments
 (0)