Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/164/json output #240

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Cli {
pub environment: String,

/// Whether more verbose output should be printed
#[clap(long, short='v', help = HelpStrings::Verbose, parse(from_occurrences), conflicts_with = "quiet", conflicts_with = "json")]
#[clap(long, short='v', help = HelpStrings::Verbose, parse(from_occurrences), conflicts_with = "quiet")]
pub verbose: usize,
morrieinmaas marked this conversation as resolved.
Show resolved Hide resolved

/// The main cli subcommands
Expand Down
5 changes: 4 additions & 1 deletion crates/cli/src/modules/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ pub async fn parse_credentials_args(
agent.send_offer(options).await.map(|cred| {
loader.stop();
log_debug!("{}", pretty_stringify_obj(&cred));
log_info!("Successfully offered a credential. Credential exchange id: ",);
log_info!(
"Successfully offered a credential. Credential exchange id: {}",
&cred.credential_exchange_id
);
copy!("{}", cred.credential_exchange_id);
log_json!({ "credential_exchange_id": cred.credential_exchange_id });
})
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/modules/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub enum WalletSubcommands {
#[clap(long, short, help=HelpStrings::WalletCreateMethod, required = true, possible_values=&["key", "sov"])]
method: String,

/// The key_type to be used ed25519 or bls12381g2
/// The key type to query for eg. ed25519, bls12381g2
#[clap(long, short, help=HelpStrings::WalletListKeyType, required = true, possible_values=&["ed25519", "bls12381g2"])]
key_type: String,
},
Expand Down Expand Up @@ -141,7 +141,7 @@ pub async fn parse_wallet_args(
};
agent.create_local_did(options).await.map(|response| {
loader.stop();
log_info!("Successfully created local DID: ",);
log_info!("Successfully created local DID: {:?}", response.did);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need debug printing for the did (I assume it is a string). If it is not a string we need to convert it.

copy!("{}", pretty_stringify_obj(&response));
log!("{}", pretty_stringify_obj(&response));
log_json!(response)
Expand Down
91 changes: 0 additions & 91 deletions crates/cloudagent-python/src/cloudagent/json_ld.rs

This file was deleted.

10 changes: 5 additions & 5 deletions crates/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct LoggerState {
pub should_copy: bool,

/// Whether the logger should log json (only)
pub should_json: bool,
pub should_output_json: bool,

/// The log level at the cli
pub level: LogLevel,
Expand All @@ -74,13 +74,13 @@ impl LoggerState {
pub const fn new(
init: bool,
should_copy: bool,
should_json: bool,
should_output_json: bool,
log_level: LogLevel,
) -> Self {
Self {
init,
should_copy,
should_json,
should_output_json,
level: log_level,
}
}
Expand All @@ -96,7 +96,7 @@ lazy_static! {
/// # Panics
///
/// When the logger is already initialized
pub fn init(level: LogLevel, should_copy: bool, should_json: bool) {
pub fn init(level: LogLevel, should_copy: bool, should_output_json: bool) {
assert!(
!STATE.read().unwrap().init,
"Logger should only be initialized once!"
Expand All @@ -105,7 +105,7 @@ pub fn init(level: LogLevel, should_copy: bool, should_json: bool) {
let mut state = STATE.write().unwrap();
state.init = true;
state.level = level;
state.should_json = should_json;
state.should_output_json = should_output_json;
state.should_copy = should_copy;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/logger/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! elog {
#[macro_export]
macro_rules! log {
($($arg:tt)*) => {
if ::siera_logger::STATE.read().unwrap().level != ::siera_logger::LogLevel::Off && !::siera_logger::STATE.read().unwrap().should_json {
if ::siera_logger::STATE.read().unwrap().level != ::siera_logger::LogLevel::Off && !::siera_logger::STATE.read().unwrap().should_output_json {
println!($($arg)*);
}
};
Expand All @@ -38,7 +38,7 @@ macro_rules! log {
#[macro_export]
macro_rules! log_json {
($($json:tt)+) => {
if ::siera_logger::STATE.read().unwrap().should_json {
if ::siera_logger::STATE.read().unwrap().should_output_json && ::siera_logger::STATE.read().unwrap().level != ::siera_logger::LogLevel::Off {
println!("{}", ::siera_logger::pretty_stringify_obj(::siera_logger::serde_json::json!($($json)+)));
}
}
Expand Down