aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock86
-rw-r--r--Cargo.toml2
-rw-r--r--crates/shirabe/Cargo.toml2
-rw-r--r--crates/shirabe/src/console/application.rs1
-rw-r--r--crates/shirabe/src/dependency_resolver/pool_builder.rs2
-rw-r--r--crates/shirabe/src/dependency_resolver/pool_optimizer.rs5
-rw-r--r--crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs1
-rw-r--r--crates/shirabe/src/dependency_resolver/solver.rs1
-rw-r--r--crates/shirabe/src/factory.rs1
-rw-r--r--crates/shirabe/src/installer.rs2
-rw-r--r--crates/shirabe/src/main.rs28
-rw-r--r--crates/shirabe/src/package/loader/array_loader.rs1
-rw-r--r--crates/shirabe/src/package/locker.rs1
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs3
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs1
-rw-r--r--crates/shirabe/src/repository/repository_set.rs1
16 files changed, 138 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a26bad27..54ff59ce 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1202,6 +1202,15 @@ dependencies = [
]
[[package]]
+name = "matchers"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
+dependencies = [
+ "regex-automata",
+]
+
+[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1273,6 +1282,15 @@ dependencies = [
]
[[package]]
+name = "nu-ansi-term"
+version = "0.50.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2028,6 +2046,15 @@ dependencies = [
]
[[package]]
+name = "sharded-slab"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
name = "shirabe"
version = "0.0.1"
dependencies = [
@@ -2055,6 +2082,8 @@ dependencies = [
"shirabe-spdx-licenses",
"tempfile",
"tokio",
+ "tracing",
+ "tracing-subscriber",
"url",
]
@@ -2302,6 +2331,15 @@ dependencies = [
]
[[package]]
+name = "thread_local"
+version = "1.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
name = "time"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2449,16 +2487,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"pin-project-lite",
+ "tracing-attributes",
"tracing-core",
]
[[package]]
+name = "tracing-attributes"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
+ "valuable",
+]
+
+[[package]]
+name = "tracing-log"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
+dependencies = [
+ "log",
+ "once_cell",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319"
+dependencies = [
+ "matchers",
+ "nu-ansi-term",
+ "once_cell",
+ "regex-automata",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing",
+ "tracing-core",
+ "tracing-log",
]
[[package]]
@@ -2541,6 +2621,12 @@ dependencies = [
]
[[package]]
+name = "valuable"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
+
+[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index e9b9fd2d..d9016c63 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,8 @@ sha1 = "0.11.0"
sha2 = "0.11.0"
tempfile = "3.27.0"
tokio = { version = "1.52.3", features = ["full"] }
+tracing = "0.1.44"
+tracing-subscriber = { version = "0.3.23", features = ["env-filter", "fmt"] }
twox-hash = "2.1.2"
url = "2.5.8"
zip = "8.6.0"
diff --git a/crates/shirabe/Cargo.toml b/crates/shirabe/Cargo.toml
index 00ce5211..22112cbe 100644
--- a/crates/shirabe/Cargo.toml
+++ b/crates/shirabe/Cargo.toml
@@ -25,6 +25,8 @@ serde.workspace = true
serde_json.workspace = true
sha1.workspace = true
tokio.workspace = true
+tracing.workspace = true
+tracing-subscriber.workspace = true
url.workspace = true
[dev-dependencies]
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs
index 577d8704..6febdf95 100644
--- a/crates/shirabe/src/console/application.rs
+++ b/crates/shirabe/src/console/application.rs
@@ -1891,6 +1891,7 @@ impl ApplicationHandle {
self.base_run(input, output)
}
+ #[tracing::instrument(skip_all)]
pub fn do_run(
&self,
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs
index 15cac540..83307d8c 100644
--- a/crates/shirabe/src/dependency_resolver/pool_builder.rs
+++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs
@@ -126,6 +126,7 @@ impl PoolBuilder {
self.allowed_types = types;
}
+ #[tracing::instrument(skip_all)]
pub fn build_pool(
&mut self,
repositories: Vec<RepositoryInterfaceHandle>,
@@ -428,6 +429,7 @@ impl PoolBuilder {
self.loaded_packages.shift_remove(name);
}
+ #[tracing::instrument(skip_all)]
fn load_packages_marked_for_loading(
&mut self,
request: &mut Request,
diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
index 789d0aed..f188d1b8 100644
--- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
+++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
@@ -57,6 +57,7 @@ impl PoolOptimizer {
}
}
+ #[tracing::instrument(skip_all)]
pub fn optimize(&mut self, request: &Request, pool: &Pool) -> Pool {
self.prepare(request, pool);
@@ -81,6 +82,7 @@ impl PoolOptimizer {
optimized_pool
}
+ #[tracing::instrument(skip_all)]
fn prepare(&mut self, request: &Request, pool: &Pool) {
let mut irremovable_package_constraint_groups: IndexMap<String, Vec<AnyConstraint>> =
IndexMap::new();
@@ -184,6 +186,7 @@ impl PoolOptimizer {
}
/// @return Pool Optimized pool
+ #[tracing::instrument(skip_all)]
fn apply_removals_to_pool(&self, pool: &Pool) -> Pool {
let mut packages: Vec<BasePackageHandle> = vec![];
let mut removed_versions: IndexMap<String, IndexMap<String, String>> = IndexMap::new();
@@ -211,6 +214,7 @@ impl PoolOptimizer {
)
}
+ #[tracing::instrument(skip_all)]
fn optimize_by_identical_dependencies(&mut self, _request: &Request, pool: &Pool) {
let mut identical_definitions_per_package: IndexMap<
String,
@@ -536,6 +540,7 @@ impl PoolOptimizer {
/// Use the list of locked packages to constrain the loaded packages
/// This will reduce packages with significant numbers of historical versions to a smaller number
/// and reduce the resulting rule set that is generated
+ #[tracing::instrument(skip_all)]
fn optimize_impossible_packages_away(&mut self, request: &Request, pool: &Pool) {
if request.get_locked_packages().is_empty() {
return;
diff --git a/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs b/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs
index 933e1d0f..59acad89 100644
--- a/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs
+++ b/crates/shirabe/src/dependency_resolver/security_advisory_pool_filter.rs
@@ -26,6 +26,7 @@ impl SecurityAdvisoryPoolFilter {
}
}
+ #[tracing::instrument(skip_all)]
pub fn filter(
&self,
pool: Pool,
diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs
index 960cd7a6..09a51ef8 100644
--- a/crates/shirabe/src/dependency_resolver/solver.rs
+++ b/crates/shirabe/src/dependency_resolver/solver.rs
@@ -220,6 +220,7 @@ impl Solver {
Ok(())
}
+ #[tracing::instrument(skip_all)]
pub fn solve(
&mut self,
request: &Request,
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index 52894b26..13697a4e 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -424,6 +424,7 @@ impl Factory {
}
/// Creates a Composer instance
+ #[tracing::instrument(skip_all)]
pub fn create_composer(
&self,
io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs
index 3cdb046b..883ee134 100644
--- a/crates/shirabe/src/installer.rs
+++ b/crates/shirabe/src/installer.rs
@@ -216,6 +216,7 @@ impl Installer {
}
/// Run installation (or update)
+ #[tracing::instrument(skip_all)]
pub fn run(&mut self) -> anyhow::Result<i64> {
// Disable GC to save CPU cycles, as the dependency solver can create hundreds of thousands
// of PHP objects, the GC can spend quite some time walking the tree of references looking
@@ -560,6 +561,7 @@ impl Installer {
Ok(0)
}
+ #[tracing::instrument(skip_all)]
pub(crate) fn do_update(
&mut self,
local_repo: crate::repository::RepositoryInterfaceHandle,
diff --git a/crates/shirabe/src/main.rs b/crates/shirabe/src/main.rs
index 6eb8e4cb..49ee61f3 100644
--- a/crates/shirabe/src/main.rs
+++ b/crates/shirabe/src/main.rs
@@ -1,6 +1,32 @@
//! ref: composer/bin/composer
use shirabe_php_shim::{PHP_ENV, PHP_SERVER};
+use std::io::IsTerminal as _;
+
+/// Initialize a tracing subscriber from the environment variable `$SHIRABE_TRACING`.
+fn init_tracing() {
+ let Ok(directives) = std::env::var("SHIRABE_TRACING") else {
+ return;
+ };
+ if directives.is_empty() {
+ return;
+ }
+
+ let env_filter = match tracing_subscriber::EnvFilter::builder().parse(&directives) {
+ Ok(env_filter) => env_filter,
+ Err(e) => {
+ eprintln!("SHIRABE_TRACING: invalid filter directives {directives:?}: {e}");
+ return;
+ }
+ };
+
+ tracing_subscriber::fmt()
+ .with_env_filter(env_filter)
+ .with_writer(std::io::stderr)
+ .with_ansi(std::io::stderr().is_terminal())
+ .with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE)
+ .init();
+}
fn main() {
// TODO(phase-c): PHP: `$xdebug = new XdebugHandler('Composer'); $xdebug->check(); unset($xdebug);`
@@ -28,6 +54,8 @@ fn main() {
.expect("failed to build the top-level tokio runtime");
let _runtime_guard = runtime.enter();
+ init_tracing();
+
let result = shirabe::run(std::env::args().collect());
let exit_code = match result {
Ok(exit_code) => exit_code,
diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs
index 3a78ff76..3ebdc488 100644
--- a/crates/shirabe/src/package/loader/array_loader.rs
+++ b/crates/shirabe/src/package/loader/array_loader.rs
@@ -192,6 +192,7 @@ impl ArrayLoader {
/// @param array<array<mixed>> $versions
///
/// @return list<CompletePackage|CompleteAliasPackage>
+ #[tracing::instrument(skip_all)]
pub fn load_packages(
&self,
versions: Vec<IndexMap<String, PhpMixed>>,
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index 535b5fdf..a2f3c0c9 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -460,6 +460,7 @@ impl Locker {
/// Locks provided data into lockfile.
#[allow(clippy::too_many_arguments, reason = "to keep PHP signature")]
+ #[tracing::instrument(skip_all)]
pub fn set_lock_data(
&mut self,
packages: Vec<PackageInterfaceHandle>,
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index 84d8fbf7..fbee87d7 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -1707,6 +1707,7 @@ impl ComposerRepository {
}
/// @param packageNames array of package name => ConstraintInterface|null - if a constraint is provided, only packages matching it will be loaded
+ #[tracing::instrument(skip_all)]
fn load_async_packages(
&mut self,
mut package_names: IndexMap<String, Option<AnyConstraint>>,
@@ -1951,6 +1952,7 @@ impl ComposerRepository {
})
}
+ #[tracing::instrument(skip_all)]
async fn start_cached_async_download(
&self,
file_name: &str,
@@ -2659,6 +2661,7 @@ impl ComposerRepository {
Ok(packages)
}
+ #[tracing::instrument(skip_all)]
fn create_packages(
&mut self,
packages: Vec<IndexMap<String, PhpMixed>>,
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 0d63940c..2b198c88 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -129,6 +129,7 @@ impl PlatformRepository {
Ok(())
}
+ #[tracing::instrument(skip_all)]
pub(crate) fn initialize(&mut self) -> anyhow::Result<()> {
self.inner.initialize();
diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs
index b858151c..c407a1ce 100644
--- a/crates/shirabe/src/repository/repository_set.rs
+++ b/crates/shirabe/src/repository/repository_set.rs
@@ -297,6 +297,7 @@ impl RepositorySet {
/// @param PackageInterface[] $packages
/// @return ($allowPartialAdvisories is true ? array{advisories: array<string, array<PartialSecurityAdvisory|SecurityAdvisory>>, unreachableRepos: array<string>} : array{advisories: array<string, array<SecurityAdvisory>>, unreachableRepos: array<string>})
+ #[tracing::instrument(skip_all)]
pub fn get_matching_security_advisories(
&self,
packages: Vec<PackageInterfaceHandle>,