use short syntax for json data in logs
This commit is contained in:
parent
f593667169
commit
376b9f474d
@ -6,6 +6,7 @@ use log::{debug, info};
|
|||||||
use migration::sea_orm::{
|
use migration::sea_orm::{
|
||||||
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, ModelTrait, QueryFilter,
|
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, ModelTrait, QueryFilter,
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
/// change a user's admin status. eiter they are an admin, or they aren't
|
/// change a user's admin status. eiter they are an admin, or they aren't
|
||||||
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
||||||
@ -35,7 +36,7 @@ impl ChangeAdminStatusSubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context(format!("No user with this id found {:?}", address))?;
|
.context(format!("No user with this id found {:?}", address))?;
|
||||||
|
|
||||||
debug!("user: {}", serde_json::to_string_pretty(&user)?);
|
debug!("user: {:#}", json!(&user));
|
||||||
|
|
||||||
// Check if there is a record in the database
|
// Check if there is a record in the database
|
||||||
match admin::Entity::find()
|
match admin::Entity::find()
|
||||||
|
@ -7,6 +7,7 @@ use migration::sea_orm::{
|
|||||||
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
/// change a user's address.
|
/// change a user's address.
|
||||||
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
||||||
@ -35,7 +36,7 @@ impl ChangeUserAddressSubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context("No user found with that address")?;
|
.context("No user found with that address")?;
|
||||||
|
|
||||||
debug!("initial user: {:#?}", u);
|
debug!("initial user: {:#}", json!(&u));
|
||||||
|
|
||||||
if u.address == new_address {
|
if u.address == new_address {
|
||||||
info!("user already has this address");
|
info!("user already has this address");
|
||||||
|
@ -6,6 +6,7 @@ use migration::sea_orm::{
|
|||||||
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
/// change a user's tier.
|
/// change a user's tier.
|
||||||
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
||||||
@ -34,7 +35,7 @@ impl ChangeUserTierSubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context("No user tier found with that name")?;
|
.context("No user tier found with that name")?;
|
||||||
|
|
||||||
debug!("initial user_tier: {:#?}", user_tier);
|
debug!("initial user_tier: {:#}", json!(&user_tier));
|
||||||
|
|
||||||
let mut user_tier = user_tier.into_active_model();
|
let mut user_tier = user_tier.into_active_model();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use migration::sea_orm::{
|
|||||||
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
/// change a user's tier.
|
/// change a user's tier.
|
||||||
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
#[derive(FromArgs, PartialEq, Eq, Debug)]
|
||||||
@ -33,7 +34,7 @@ impl ChangeUserTierByAddressSubCommand {
|
|||||||
.context("No user found with that key")?;
|
.context("No user found with that key")?;
|
||||||
|
|
||||||
// TODO: don't serialize the rpc key
|
// TODO: don't serialize the rpc key
|
||||||
debug!("user: {:#?}", user);
|
debug!("user: {:#}", json!(&user));
|
||||||
|
|
||||||
// use the title to get the user tier
|
// use the title to get the user tier
|
||||||
let user_tier = user_tier::Entity::find()
|
let user_tier = user_tier::Entity::find()
|
||||||
@ -42,7 +43,7 @@ impl ChangeUserTierByAddressSubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context("No user tier found with that name")?;
|
.context("No user tier found with that name")?;
|
||||||
|
|
||||||
debug!("user_tier: {:#?}", user_tier);
|
debug!("user_tier: {:#}", json!(&user_tier));
|
||||||
|
|
||||||
if user.user_tier_id == user_tier.id {
|
if user.user_tier_id == user_tier.id {
|
||||||
info!("user already has that tier");
|
info!("user already has that tier");
|
||||||
|
@ -6,6 +6,7 @@ use migration::sea_orm::{
|
|||||||
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
};
|
};
|
||||||
|
use serde_json::json;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use web3_proxy::frontend::authorization::RpcSecretKey;
|
use web3_proxy::frontend::authorization::RpcSecretKey;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ impl ChangeUserTierByKeySubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context("No user tier found with that name")?;
|
.context("No user tier found with that name")?;
|
||||||
|
|
||||||
debug!("user_tier: {:#?}", user_tier);
|
debug!("user_tier: {:#}", json!(&user_tier));
|
||||||
|
|
||||||
// use the rpc secret key to get the user
|
// use the rpc secret key to get the user
|
||||||
let user = user::Entity::find()
|
let user = user::Entity::find()
|
||||||
@ -44,7 +45,7 @@ impl ChangeUserTierByKeySubCommand {
|
|||||||
.await?
|
.await?
|
||||||
.context("No user found with that key")?;
|
.context("No user found with that key")?;
|
||||||
|
|
||||||
debug!("user: {:#?}", user);
|
debug!("user: {:#}", json!(&user));
|
||||||
|
|
||||||
if user.user_tier_id == user_tier.id {
|
if user.user_tier_id == user_tier.id {
|
||||||
info!("user already has that tier");
|
info!("user already has that tier");
|
||||||
|
@ -250,7 +250,6 @@ impl MigrateStatsToV2 {
|
|||||||
|
|
||||||
// Wait for any tasks that are on-going
|
// Wait for any tasks that are on-going
|
||||||
while let Some(x) = important_background_handles.next().await {
|
while let Some(x) = important_background_handles.next().await {
|
||||||
info!("Returned item is: {:?}", x);
|
|
||||||
match x {
|
match x {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{:?}", e);
|
error!("{:?}", e);
|
||||||
@ -261,8 +260,6 @@ impl MigrateStatsToV2 {
|
|||||||
Ok(Ok(_)) => {
|
Ok(Ok(_)) => {
|
||||||
// TODO: how can we know which handle exited?
|
// TODO: how can we know which handle exited?
|
||||||
info!("a background handle exited");
|
info!("a background handle exited");
|
||||||
// Pop it in this case?
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use pagerduty_rs::{eventsv2async::EventsV2 as PagerdutyAsyncEventsV2, types::Event};
|
use pagerduty_rs::{eventsv2async::EventsV2 as PagerdutyAsyncEventsV2, types::Event};
|
||||||
|
use serde_json::json;
|
||||||
use web3_proxy::{
|
use web3_proxy::{
|
||||||
config::TopConfig,
|
config::TopConfig,
|
||||||
pagerduty::{pagerduty_alert, pagerduty_alert_for_config},
|
pagerduty::{pagerduty_alert, pagerduty_alert_for_config},
|
||||||
@ -68,18 +69,15 @@ impl PagerdutySubCommand {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(pagerduty_async) = pagerduty_async {
|
if let Some(pagerduty_async) = pagerduty_async {
|
||||||
info!(
|
info!("sending to pagerduty: {:#}", json!(&event));
|
||||||
"sending to pagerduty: {}",
|
|
||||||
serde_json::to_string_pretty(&event)?
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Err(err) = pagerduty_async.event(Event::AlertTrigger(event)).await {
|
if let Err(err) = pagerduty_async.event(Event::AlertTrigger(event)).await {
|
||||||
error!("Failed sending to pagerduty: {}", err);
|
error!("Failed sending to pagerduty: {}", err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"would send to pagerduty if PAGERDUTY_INTEGRATION_KEY were set: {}",
|
"would send to pagerduty if PAGERDUTY_INTEGRATION_KEY were set: {:#}",
|
||||||
serde_json::to_string_pretty(&event)?
|
json!(&event)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,10 +142,7 @@ impl SentrydSubCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if let Some(ref pagerduty_async) = pagerduty_async {
|
if let Some(ref pagerduty_async) = pagerduty_async {
|
||||||
info!(
|
info!("sending to pagerduty: {:#}", json!(&alert));
|
||||||
"sending to pagerduty: {:#}",
|
|
||||||
serde_json::to_string_pretty(&alert)?
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Err(err) =
|
if let Err(err) =
|
||||||
pagerduty_async.event(Event::AlertTrigger(alert)).await
|
pagerduty_async.event(Event::AlertTrigger(alert)).await
|
||||||
|
Loading…
Reference in New Issue
Block a user