Skip to content

Commit

Permalink
Extract log collector crate (#2025)
Browse files Browse the repository at this point in the history
* extract log-collector crate

* update log-collector dependents

* cargo sort

* fmt
  • Loading branch information
kevinheavey authored Jul 9, 2024
1 parent 3079181 commit ddee03e
Show file tree
Hide file tree
Showing 35 changed files with 99 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ target/
*.log
log-*.txt
log-*/
!log-collector/
!log-analyzer/*

# intellij files
Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ members = [
"ledger-tool",
"local-cluster",
"log-analyzer",
"log-collector",
"logger",
"measure",
"memory-management",
Expand Down Expand Up @@ -365,6 +366,7 @@ solana-inline-spl = { path = "inline-spl", version = "=2.1.0" }
solana-ledger = { path = "ledger", version = "=2.1.0" }
solana-loader-v4-program = { path = "programs/loader-v4", version = "=2.1.0" }
solana-local-cluster = { path = "local-cluster", version = "=2.1.0" }
solana-log-collector = { path = "log-collector", version = "=2.1.0" }
solana-logger = { path = "logger", version = "=2.1.0" }
solana-measure = { path = "measure", version = "=2.1.0" }
solana-merkle-tree = { path = "merkle-tree", version = "=2.1.0" }
Expand Down
1 change: 1 addition & 0 deletions ledger-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ solana-entry = { workspace = true }
solana-geyser-plugin-manager = { workspace = true }
solana-gossip = { workspace = true }
solana-ledger = { workspace = true, features = ["dev-context-only-utils"] }
solana-log-collector = { workspace = true }
solana-logger = { workspace = true }
solana-measure = { workspace = true }
solana-program-runtime = { workspace = true }
Expand Down
16 changes: 16 additions & 0 deletions log-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "solana-log-collector"
description = "Solana log collector"
documentation = "https://docs.rs/solana-log-collector"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
log = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl LogCollector {
#[macro_export]
macro_rules! ic_logger_msg {
($log_collector:expr, $message:expr) => {
$crate::log_collector::log::debug!(
$crate::log::debug!(
target: "solana_runtime::message_processor::stable_log",
"{}",
$message
Expand All @@ -76,7 +76,7 @@ macro_rules! ic_logger_msg {
}
};
($log_collector:expr, $fmt:expr, $($arg:tt)*) => {
$crate::log_collector::log::debug!(
$crate::log::debug!(
target: "solana_runtime::message_processor::stable_log",
$fmt,
$($arg)*
Expand Down
1 change: 1 addition & 0 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde = { workspace = true }
solana-compute-budget = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-log-collector = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-sdk = { workspace = true }
Expand Down
5 changes: 2 additions & 3 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use {
crate::{
ic_msg,
loaded_programs::{
ProgramCacheEntry, ProgramCacheEntryType, ProgramCacheForTxBatch,
ProgramRuntimeEnvironments,
},
log_collector::LogCollector,
stable_log,
sysvar_cache::SysvarCache,
timings::{ExecuteDetailsTimings, ExecuteTimings},
},
solana_compute_budget::compute_budget::ComputeBudget,
solana_log_collector::{ic_msg, LogCollector},
solana_measure::measure::Measure,
solana_rbpf::{
ebpf::MM_HEAP_START,
Expand Down Expand Up @@ -677,6 +676,7 @@ macro_rules! with_mock_invoke_context {
) => {
use {
solana_compute_budget::compute_budget::ComputeBudget,
solana_log_collector::LogCollector,
solana_sdk::{
account::ReadableAccount, feature_set::FeatureSet, hash::Hash, sysvar::rent::Rent,
transaction_context::TransactionContext,
Expand All @@ -685,7 +685,6 @@ macro_rules! with_mock_invoke_context {
$crate::{
invoke_context::{EnvironmentConfig, InvokeContext},
loaded_programs::ProgramCacheForTxBatch,
log_collector::LogCollector,
sysvar_cache::SysvarCache,
},
};
Expand Down
1 change: 0 additions & 1 deletion program-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ extern crate solana_metrics;
pub use solana_rbpf;
pub mod invoke_context;
pub mod loaded_programs;
pub mod log_collector;
pub mod mem_pool;
pub mod stable_log;
pub mod sysvar_cache;
Expand Down
2 changes: 1 addition & 1 deletion program-runtime/src/stable_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! The format of these log messages should not be modified to avoid breaking downstream consumers
//! of program logging
use {
crate::{ic_logger_msg, log_collector::LogCollector},
base64::{prelude::BASE64_STANDARD, Engine},
itertools::Itertools,
solana_log_collector::{ic_logger_msg, LogCollector},
solana_sdk::pubkey::Pubkey,
std::{cell::RefCell, rc::Rc},
};
Expand Down
1 change: 1 addition & 0 deletions program-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ solana-banks-server = { workspace = true }
solana-bpf-loader-program = { workspace = true }
solana-compute-budget = { workspace = true }
solana-inline-spl = { workspace = true }
solana-log-collector = { workspace = true }
solana-logger = { workspace = true }
solana-program-runtime = { workspace = true }
solana-runtime = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use {
solana_banks_server::banks_server::start_local_server,
solana_bpf_loader_program::serialization::serialize_parameters,
solana_compute_budget::compute_budget::ComputeBudget,
solana_log_collector::ic_msg,
solana_program_runtime::{
ic_msg, invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry,
stable_log, timings::ExecuteTimings,
invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry, stable_log,
timings::ExecuteTimings,
},
solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestKind},
Expand Down
1 change: 1 addition & 0 deletions programs/address-lookup-table/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ solana-program = { workspace = true }
thiserror = { workspace = true }

[target.'cfg(not(target_os = "solana"))'.dependencies]
solana-log-collector = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }

Expand Down
3 changes: 2 additions & 1 deletion programs/address-lookup-table/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
solana_program_runtime::{declare_process_instruction, ic_msg, invoke_context::InvokeContext},
solana_log_collector::ic_msg,
solana_program_runtime::{declare_process_instruction, invoke_context::InvokeContext},
solana_sdk::{
address_lookup_table::{
instruction::ProgramInstruction,
Expand Down
1 change: 1 addition & 0 deletions programs/bpf_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ log = { workspace = true }
scopeguard = { workspace = true }
solana-compute-budget = { workspace = true }
solana-curve25519 = { workspace = true }
solana-log-collector = { workspace = true }
solana-measure = { workspace = true }
solana-poseidon = { workspace = true }
solana-program-runtime = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ pub mod syscalls;

use {
solana_compute_budget::compute_budget::MAX_INSTRUCTION_STACK_DEPTH,
solana_log_collector::{ic_logger_msg, ic_msg, LogCollector},
solana_measure::measure::Measure,
solana_program_runtime::{
ic_logger_msg, ic_msg,
invoke_context::{BpfAllocator, InvokeContext, SerializedAccountMetadata, SyscallContext},
loaded_programs::{
LoadProgramMetrics, ProgramCacheEntry, ProgramCacheEntryOwner, ProgramCacheEntryType,
DELAY_VISIBILITY_SLOT_OFFSET,
},
log_collector::LogCollector,
mem_pool::VmMemoryPool,
stable_log,
sysvar_cache::get_sysvar_with_account_check,
Expand Down
5 changes: 2 additions & 3 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ pub use self::{
#[allow(deprecated)]
use {
solana_compute_budget::compute_budget::ComputeBudget,
solana_log_collector::{ic_logger_msg, ic_msg},
solana_poseidon as poseidon,
solana_program_runtime::{
ic_logger_msg, ic_msg, invoke_context::InvokeContext, stable_log, timings::ExecuteTimings,
},
solana_program_runtime::{invoke_context::InvokeContext, stable_log, timings::ExecuteTimings},
solana_rbpf::{
declare_builtin_function,
memory_region::{AccessType, MemoryMapping},
Expand Down
1 change: 1 addition & 0 deletions programs/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bincode = { workspace = true }
chrono = { workspace = true, features = ["default", "serde"] }
serde = { workspace = true }
serde_derive = { workspace = true }
solana-log-collector = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }

Expand Down
3 changes: 2 additions & 1 deletion programs/config/src/config_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
use {
crate::ConfigKeys,
bincode::deserialize,
solana_program_runtime::{declare_process_instruction, ic_msg},
solana_log_collector::ic_msg,
solana_program_runtime::declare_process_instruction,
solana_sdk::{
instruction::InstructionError, program_utils::limited_deserialize, pubkey::Pubkey,
transaction_context::IndexOfAccount,
Expand Down
1 change: 1 addition & 0 deletions programs/loader-v4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = { workspace = true }
[dependencies]
log = { workspace = true }
solana-compute-budget = { workspace = true }
solana-log-collector = { workspace = true }
solana-measure = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions programs/loader-v4/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use {
solana_compute_budget::compute_budget::ComputeBudget,
solana_log_collector::{ic_logger_msg, LogCollector},
solana_measure::measure::Measure,
solana_program_runtime::{
ic_logger_msg,
invoke_context::InvokeContext,
loaded_programs::{
LoadProgramMetrics, ProgramCacheEntry, ProgramCacheEntryType,
DELAY_VISIBILITY_SLOT_OFFSET,
},
log_collector::LogCollector,
stable_log,
},
solana_rbpf::{
Expand Down
Loading

0 comments on commit ddee03e

Please sign in to comment.