Skip to content

Commit

Permalink
Change dbg! to debug!
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Feb 1, 2022
1 parent 115e13a commit 9696c30
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 196 deletions.
3 changes: 1 addition & 2 deletions applications/tari_collectibles/src-tauri/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ use crate::{
};
use std::{path::PathBuf, sync::Arc};

use tari_app_utilities::initialization::init_configuration;
use tari_common::configuration::{bootstrap::ApplicationType, CollectiblesConfig};
use tari_common::configuration::CollectiblesConfig;
use tauri::async_runtime::RwLock;
use uuid::Uuid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl BaseNodeClient {
unique_ids: vec![vec![3u8; 32]],
};

dbg!(&request);
debug!(target: LOG_TARGET, "request {:?}", request);
let mut stream = client
.get_tokens(request)
.await
Expand All @@ -120,7 +120,7 @@ impl BaseNodeClient {
if i > 10 {
break;
}
dbg!(&response);
debug!(target: LOG_TARGET, "response {:?}", response);
let features = response
.map_err(|status| format!("Got an error status from GRPC:{}", status))?
.features;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use crate::error::CollectiblesError;
use log::debug;
use log::{debug, error};
use tari_app_grpc::tari_rpc as grpc;
use tari_common_types::types::PublicKey;
use tari_utilities::ByteArray;
Expand Down Expand Up @@ -60,21 +60,21 @@ impl GrpcValidatorNodeClient {
method,
args,
};
debug!(target: LOG_TARGET, "{:?}", req);
debug!(target: LOG_TARGET, "req {:?}", req);
let response = self
.client
.invoke_read_method(req)
.await
.map(|resp| resp.into_inner())
.map_err(|e| {
dbg!(&e);
error!(target: LOG_TARGET, "{}", e);

CollectiblesError::ClientRequestError {
source: e,
request: "invoke_read_method".to_string(),
}
})?;
debug!(target: LOG_TARGET, "{:?}", response);
debug!(target: LOG_TARGET, "response {:?}", response);
Ok(response.result)
}

Expand All @@ -91,21 +91,21 @@ impl GrpcValidatorNodeClient {
method,
args,
};
dbg!(&req);
debug!(target: LOG_TARGET, "req {:?}", req);
let response = self
.client
.invoke_method(req)
.await
.map(|resp| resp.into_inner())
.map_err(|e| {
dbg!(&e);
error!(target: LOG_TARGET, "{}", e);

CollectiblesError::ClientRequestError {
source: e,
request: "invoke_method".to_string(),
}
})?;
dbg!(&response);
debug!(target: LOG_TARGET, "response {:?}", response);
Ok(response.result)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl WalletClient {
source: error,
}
})?;
dbg!(&result);
debug!(target: LOG_TARGET, "result {:?}", result);
Ok(result.into_inner().public_key.to_hex())
}

Expand All @@ -94,7 +94,7 @@ impl WalletClient {
source,
}
})?;
debug!(target: LOG_TARGET, "{:?}", result);
debug!(target: LOG_TARGET, "result {:?}", result);
Ok(result.into_inner())
}

Expand All @@ -120,7 +120,7 @@ impl WalletClient {
request: "create_initial_asset_checkpoint".to_string(),
source,
})?;
debug!(target: LOG_TARGET, "{:?}", &result);
debug!(target: LOG_TARGET, "result {:?}", result);
Ok(result.into_inner())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ use crate::{
StorageTransaction,
},
};
use log::{debug, error};
use prost::Message;
use tari_common_types::types::PublicKey;
use tari_dan_common_types::proto::tips::tip002;
use tari_utilities::{hex::Hex, ByteArray};
use tauri::Manager;
use uuid::Uuid;

const LOG_TARGET: &str = "collectibles::asset_wallets";

#[tauri::command]
pub(crate) async fn asset_wallets_create(
asset_public_key: String,
Expand Down Expand Up @@ -84,7 +87,7 @@ pub(crate) async fn asset_wallets_create(
}
}
Err(e) => {
dbg!(e);
error!(target: LOG_TARGET, "{}", e);
None
}
};
Expand Down Expand Up @@ -121,7 +124,10 @@ pub(crate) async fn asset_wallets_get_balance(
asset_public_key: String,
state: tauri::State<'_, ConcurrentAppState>,
) -> Result<u64, Status> {
dbg!(&asset_public_key);
debug!(
target: LOG_TARGET,
"asset_public_key {:?}", asset_public_key
);
let asset_public_key = PublicKey::from_hex(&asset_public_key)?;

let wallet_id = state
Expand All @@ -143,7 +149,7 @@ pub(crate) async fn asset_wallets_get_balance(
let args = tip002::BalanceOfRequest {
owner: Vec::from(owner.public_key.as_bytes()),
};
dbg!(&args);
debug!(target: LOG_TARGET, "args {:?}", args);
let mut args_bytes = vec![];
args.encode(&mut args_bytes)?;
// let req = grpc::InvokeReadMethodRequest{
Expand All @@ -162,7 +168,7 @@ pub(crate) async fn asset_wallets_get_balance(
)
.await?;

dbg!(&resp);
debug!(target: LOG_TARGET, "resp {:?}", resp);
let proto_resp: tip002::BalanceOfResponse = Message::decode(&*resp)?;
total += proto_resp.balance;
}
Expand Down Expand Up @@ -219,7 +225,7 @@ pub(crate) async fn asset_wallets_create_address(
public_key: address_public_key,
key_manager_path,
};
dbg!(&address);
debug!(target: LOG_TARGET, "address {:?}", address);
db.addresses().insert(&address, &transaction)?;
transaction.commit()?;
Ok(address)
Expand Down Expand Up @@ -295,6 +301,6 @@ pub(crate) async fn asset_wallets_send_to(
.invoke_method(asset_public_key, 2, "transfer".to_string(), args_bytes)
.await?;

dbg!(&resp);
debug!(target: LOG_TARGET, "resp {:?}", resp);
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ pub(crate) async fn assets_create(
image: Some(image),
committee: None,
};
dbg!(&asset_row);
debug!(target: LOG_TARGET, "asset_row {:?}", asset_row);
db.assets().insert(&asset_row, &transaction)?;
let asset_wallet_row = AssetWalletRow {
id: Uuid::new_v4(),
asset_id,
wallet_id,
};
dbg!(&asset_wallet_row);
debug!(
target: LOG_TARGET,
"asset_wallet_row {:?}", asset_wallet_row
);
db.asset_wallets().insert(&asset_wallet_row, &transaction)?;
let address = AddressRow {
id: Uuid::new_v4(),
Expand All @@ -115,7 +118,7 @@ pub(crate) async fn assets_create(
public_key: asset_public_key,
key_manager_path: key_manager_path.clone(),
};
dbg!(&address);
debug!(target: LOG_TARGET, "address {:?}", address);
db.addresses().insert(&address, &transaction)?;
if template_ids.contains(&2) {
let row = Tip002AddressRow {
Expand Down Expand Up @@ -262,7 +265,7 @@ pub(crate) async fn assets_get_registration(
let asset_pub_key = PublicKey::from_hex(&asset_pub_key)?;
let asset = client.get_asset_metadata(&asset_pub_key).await?;

debug!(target: LOG_TARGET, "{:?}", asset);
debug!(target: LOG_TARGET, "asset {:?}", asset);
let features = asset.features.unwrap();
let serializer = V1AssetMetadataSerializer {};
let metadata = serializer.deserialize(&features.metadata[1..]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) async fn tip004_mint_token(
let result = client
.invoke_method(asset_public_key, 4, "mint".to_string(), bytes)
.await?;
dbg!(&result);
debug!(target: LOG_TARGET, "result {:?}", result);
Ok(())
}

Expand Down Expand Up @@ -99,7 +99,7 @@ pub(crate) async fn tip004_list_tokens(
args.encode_to_vec(),
)
.await?;
debug!(target: LOG_TARGET, "{:?}", result);
debug!(target: LOG_TARGET, "result {:?}", result);
db.tip721_tokens().delete_all_for_address(address.id, &tx)?;
if !result.is_empty() {
let balance_of: tip004::BalanceOfResponse = Message::decode(&*result)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ use crate::{
status::Status,
storage::{AddressesTableGateway, AssetsTableGateway, CollectiblesStorage},
};
use log::debug;
use prost::Message;
use tari_common_types::types::PublicKey;
use tari_dan_common_types::proto::tips::tip721;
use tari_utilities::{hex::Hex, ByteArray};
use uuid::Uuid;

const LOG_TARGET: &str = "collectibles::tip721";

#[tauri::command]
pub(crate) async fn tip721_transfer_from(
asset_public_key: String,
Expand Down Expand Up @@ -72,6 +75,6 @@ pub(crate) async fn tip721_transfer_from(
transfer_request,
)
.await?;
dbg!(&res);
debug!(target: LOG_TARGET, "res {:?}", res);
Ok(())
}
1 change: 0 additions & 1 deletion applications/tari_collectibles/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
windows_subsystem = "windows"
)]

use log::error;
use tari_app_utilities::initialization::init_configuration;
use tari_common::configuration::bootstrap::ApplicationType;

Expand Down
Empty file.
13 changes: 11 additions & 2 deletions common/config/presets/collectibles.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[collectibles]
########################################################################################################################
# #
# Collectibles Configuration Options #
# #
########################################################################################################################
########################################################################################################################

[collectibles]
# GRPC address of validator node
#validator_node_grpc_address = 127.0.0.1:18144

# GRPC address of base node
#base_node_grpc_address = 127.0.0.1:18142

# GRPC address of wallet
#wallet_grpc_address = 127.0.0.1:18143
3 changes: 2 additions & 1 deletion common/config/presets/validator_node.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[validator_node]
########################################################################################################################
# #
# Validator Node Configuration Options #
# #
########################################################################################################################

[validator_node]

committee = ["2ea0df3059caf4411624d6bf5b9c02238d607d2798c586b3e6c2a054da3f205a"] # cannot be of zero size
phase_timeout = 30
template_id = "EditableMetadata"
18 changes: 9 additions & 9 deletions common/logging/log4rs_collectibles.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# A sample log configuration file for running in release mode. By default, this configuration splits up log messages to
# three destinations:
# * Console: For log messages with level INFO and higher
# * log/base-node/network.log: INFO-level logs related to the comms crate. This file will be quite busy since there
# * log/collectibles/network.log: INFO-level logs related to the comms crate. This file will be quite busy since there
# are lots of P2P debug messages, and so this traffic is segregated from the application log messages
# * log/base-node/base_layer.log: Non-comms related INFO-level messages and higher are logged into this file
# * log/base-node/other.log: Third-party crates' messages will be logged here at an ERROR level
# * log/collectibles/base_layer.log: Non-comms related INFO-level messages and higher are logged into this file
# * log/collectibles/other.log: Third-party crates' messages will be logged here at an ERROR level
#
# See https://docs.rs/log4rs/0.8.3/log4rs/encode/pattern/index.html for deciphering the log pattern. The log format
# used in this sample configuration prints messages as:
Expand All @@ -24,7 +24,7 @@ appenders:
# An appender named "network" that writes to a file with a custom pattern encoder
network:
kind: rolling_file
path: "log/base-node/network.log"
path: "log/collectibles/network.log"
policy:
kind: compound
trigger:
Expand All @@ -34,14 +34,14 @@ appenders:
kind: fixed_window
base: 1
count: 5
pattern: "log/base-node/network.{}.log"
pattern: "log/collectibles/network.{}.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

# An appender named "base_layer" that writes to a file with a custom pattern encoder
base_layer:
kind: rolling_file
path: "log/base-node/base_layer.log"
path: "log/collectibles/base_layer.log"
policy:
kind: compound
trigger:
Expand All @@ -51,14 +51,14 @@ appenders:
kind: fixed_window
base: 1
count: 5
pattern: "log/base-node/base_layer.{}.log"
pattern: "log/collectibles/base_layer.{}.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] [{X(node-public-key)},{X(node-id)}] {l:5} {m}{n}"

# An appender named "other" that writes to a file with a custom pattern encoder
other:
kind: rolling_file
path: "log/base-node/other.log"
path: "log/collectibles/other.log"
policy:
kind: compound
trigger:
Expand All @@ -68,7 +68,7 @@ appenders:
kind: fixed_window
base: 1
count: 5
pattern: "log/base-node/other.{}.log"
pattern: "log/collectibles/other.{}.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] [Thread:{I}] {l:5} {m}{n}"

Expand Down
1 change: 0 additions & 1 deletion common/src/configuration/collectibles_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ impl CollectiblesConfig {
Ok(s) => s,
Err(_e) => {
// dbg!(e);
println!("{}:{}", file!(), line!());
return Ok(None);
},
};
Expand Down
Loading

0 comments on commit 9696c30

Please sign in to comment.