Clients: log git commit info at start time (#965)
(cherry picked from commit 53829cb6e5
)
This commit is contained in:
parent
2a5fdc89e6
commit
15f623ce9f
|
@ -315,9 +315,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.75"
|
version = "1.0.86"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
|
@ -3491,6 +3491,7 @@ dependencies = [
|
||||||
"tokio-tungstenite 0.17.2",
|
"tokio-tungstenite 0.17.2",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"vergen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4229,6 +4230,15 @@ dependencies = [
|
||||||
"syn 2.0.37",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_threads"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "number_prefix"
|
name = "number_prefix"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -8392,6 +8402,8 @@ checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
"itoa",
|
||||||
|
"libc",
|
||||||
|
"num_threads",
|
||||||
"serde",
|
"serde",
|
||||||
"time-core",
|
"time-core",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
|
@ -9277,6 +9289,18 @@ version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vergen"
|
||||||
|
version = "8.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"rustversion",
|
||||||
|
"time 0.3.29",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
|
|
@ -89,6 +89,7 @@ enum Command {
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), anyhow::Error> {
|
async fn main() -> Result<(), anyhow::Error> {
|
||||||
mango_v4_client::tracing_subscriber_init();
|
mango_v4_client::tracing_subscriber_init();
|
||||||
|
mango_v4_client::print_git_version();
|
||||||
|
|
||||||
let args = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
let args = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
||||||
dotenv::from_path(cli_dotenv.dotenv)?;
|
dotenv::from_path(cli_dotenv.dotenv)?;
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub fn encode_address(addr: &Pubkey) -> String {
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
mango_v4_client::tracing_subscriber_init();
|
mango_v4_client::tracing_subscriber_init();
|
||||||
|
mango_v4_client::print_git_version();
|
||||||
|
|
||||||
let args: Vec<std::ffi::OsString> = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
let args: Vec<std::ffi::OsString> = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
||||||
dotenv::from_path(cli_dotenv.dotenv)?;
|
dotenv::from_path(cli_dotenv.dotenv)?;
|
||||||
|
|
|
@ -80,6 +80,7 @@ pub fn encode_address(addr: &Pubkey) -> String {
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
mango_v4_client::tracing_subscriber_init();
|
mango_v4_client::tracing_subscriber_init();
|
||||||
|
mango_v4_client::print_git_version();
|
||||||
|
|
||||||
let args = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
let args = if let Ok(cli_dotenv) = CliDotenv::try_parse() {
|
||||||
dotenv::from_path(cli_dotenv.dotenv)?;
|
dotenv::from_path(cli_dotenv.dotenv)?;
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
name = "mango-v4-client"
|
name = "mango-v4-client"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
|
vergen = { version = "8.3.1", features = ["git", "gitcl"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anchor-client = { workspace = true }
|
anchor-client = { workspace = true }
|
||||||
anchor-lang = { workspace = true }
|
anchor-lang = { workspace = true }
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
use vergen::EmitBuilder;
|
||||||
|
|
||||||
|
pub fn main() -> anyhow::Result<()> {
|
||||||
|
EmitBuilder::builder()
|
||||||
|
.git_sha(true)
|
||||||
|
.git_dirty(false)
|
||||||
|
.git_commit_date()
|
||||||
|
.emit()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ use solana_sdk::instruction::Instruction;
|
||||||
|
|
||||||
use anchor_lang::prelude::{AccountMeta, Pubkey};
|
use anchor_lang::prelude::{AccountMeta, Pubkey};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
/// Some Result<> types don't convert to anyhow::Result nicely. Force them through stringification.
|
/// Some Result<> types don't convert to anyhow::Result nicely. Force them through stringification.
|
||||||
pub trait AnyhowWrap {
|
pub trait AnyhowWrap {
|
||||||
|
@ -59,6 +60,19 @@ pub fn tracing_subscriber_init() {
|
||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn print_git_version() {
|
||||||
|
info!(
|
||||||
|
"version is {}[{}{}]",
|
||||||
|
env!("VERGEN_GIT_SHA"),
|
||||||
|
env!("VERGEN_GIT_COMMIT_DATE"),
|
||||||
|
if env!("VERGEN_GIT_DIRTY") == "true" {
|
||||||
|
"-dirty"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn http_error_handling<T: serde::de::DeserializeOwned>(
|
pub async fn http_error_handling<T: serde::de::DeserializeOwned>(
|
||||||
response: reqwest::Response,
|
response: reqwest::Response,
|
||||||
) -> anyhow::Result<T> {
|
) -> anyhow::Result<T> {
|
||||||
|
|
Loading…
Reference in New Issue