Skip to content

Commit f93da31

Browse files
committed
ref(*): Standardize on using tracing::* instead of tracing::log::*
This decreases our dependency on the Rust tracing-log compatability layer Signed-off-by: Caleb Schoepp <[email protected]>
1 parent b3db535 commit f93da31

File tree

11 files changed

+20
-25
lines changed

11 files changed

+20
-25
lines changed

crates/http/src/wagi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn compose_response(stdout: &[u8]) -> Result<Response<Body>, Error> {
263263
match status_code.parse::<StatusCode>() {
264264
Ok(code) => *res.status_mut() = code,
265265
Err(e) => {
266-
tracing::log::warn!("Failed to parse code: {}", e);
266+
tracing::warn!("Failed to parse code: {}", e);
267267
*res.status_mut() = StatusCode::BAD_GATEWAY;
268268
}
269269
}

crates/oci/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl Client {
490490

491491
/// Create a new wasm layer based on a file.
492492
async fn wasm_layer(file: &Path) -> Result<ImageLayer> {
493-
tracing::log::trace!("Reading wasm module from {:?}", file);
493+
tracing::trace!("Reading wasm module from {:?}", file);
494494
Ok(ImageLayer::new(
495495
fs::read(file).await.context("cannot read wasm module")?,
496496
WASM_LAYER_MEDIA_TYPE.to_string(),
@@ -500,7 +500,7 @@ impl Client {
500500

501501
/// Create a new data layer based on a file.
502502
async fn data_layer(file: &Path, media_type: String) -> Result<ImageLayer> {
503-
tracing::log::trace!("Reading data file from {:?}", file);
503+
tracing::trace!("Reading data file from {:?}", file);
504504
Ok(ImageLayer::new(fs::read(&file).await?, media_type, None))
505505
}
506506

crates/outbound-http/src/host_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ impl outbound_http::Host for OutboundHttp {
6060
}
6161
}
6262

63-
tracing::log::trace!("Attempting to send outbound HTTP request to {}", req.uri);
63+
tracing::trace!("Attempting to send outbound HTTP request to {}", req.uri);
6464
if !self
6565
.is_allowed(&req.uri)
6666
.map_err(|_| HttpError::RuntimeError)?
6767
{
68-
tracing::log::info!("Destination not allowed: {}", req.uri);
68+
tracing::info!("Destination not allowed: {}", req.uri);
6969
if let Some((scheme, host_and_port)) = scheme_host_and_port(&req.uri) {
7070
terminal::warn!("A component tried to make a HTTP request to non-allowed host '{host_and_port}'.");
7171
eprintln!("To allow requests, add 'allowed_outbound_hosts = [\"{scheme}://{host_and_port}\"]' to the manifest component section.");
@@ -88,7 +88,7 @@ impl outbound_http::Host for OutboundHttp {
8888
let body = req.body.unwrap_or_default().to_vec();
8989

9090
if !req.params.is_empty() {
91-
tracing::log::warn!("HTTP params field is deprecated");
91+
tracing::warn!("HTTP params field is deprecated");
9292
}
9393

9494
// Allow reuse of Client's internal connection pool for multiple requests
@@ -102,7 +102,7 @@ impl outbound_http::Host for OutboundHttp {
102102
.send()
103103
.await
104104
.map_err(log_reqwest_error)?;
105-
tracing::log::trace!("Returning response from outbound request to {}", req.uri);
105+
tracing::trace!("Returning response from outbound request to {}", req.uri);
106106
current_span.record("http.response.status_code", resp.status().as_u16());
107107
response_from_reqwest(resp).await
108108
}

crates/outbound-mysql/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ fn convert_value(value: mysql_async::Value, column: &Column) -> Result<DbValue,
348348
}
349349

350350
async fn build_conn(address: &str) -> Result<mysql_async::Conn, mysql_async::Error> {
351-
tracing::log::debug!("Build new connection: {}", address);
351+
tracing::debug!("Build new connection: {}", address);
352352

353353
let opts = build_opts(address)?;
354354

crates/plugins/src/lookup.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{
44
fs::File,
55
path::{Path, PathBuf},
66
};
7-
use tracing::log;
87
use url::Url;
98

109
// Name of directory that contains the cloned centralized Spin plugins
@@ -62,7 +61,7 @@ impl PluginLookup {
6261
plugins_dir: &Path,
6362
) -> PluginLookupResult<PluginManifest> {
6463
let url = plugins_repo_url()?;
65-
log::info!("Pulling manifest for plugin {} from {url}", self.name);
64+
tracing::info!("Pulling manifest for plugin {} from {url}", self.name);
6665
fetch_plugins_repo(&url, plugins_dir, false)
6766
.await
6867
.map_err(|e| {

crates/plugins/src/manager.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::{
1616
path::{Path, PathBuf},
1717
};
1818
use tempfile::{tempdir, TempDir};
19-
use tracing::log;
2019
use url::Url;
2120

2221
// Url scheme prefix of a plugin that is installed from a local source
@@ -189,7 +188,7 @@ impl PluginManager {
189188
) -> PluginLookupResult<PluginManifest> {
190189
let plugin_manifest = match manifest_location {
191190
ManifestLocation::Remote(url) => {
192-
log::info!("Pulling manifest for plugin from {url}");
191+
tracing::info!("Pulling manifest for plugin from {url}");
193192
reqwest::get(url.as_ref())
194193
.await
195194
.map_err(|e| {
@@ -216,7 +215,7 @@ impl PluginManager {
216215
})?
217216
}
218217
ManifestLocation::Local(path) => {
219-
log::info!("Pulling manifest for plugin from {}", path.display());
218+
tracing::info!("Pulling manifest for plugin from {}", path.display());
220219
let file = File::open(path).map_err(|e| {
221220
Error::NotFound(NotFoundError::new(
222221
None,
@@ -336,7 +335,7 @@ pub fn get_package(plugin_manifest: &PluginManifest) -> Result<&PluginPackage> {
336335
}
337336

338337
async fn download_plugin(name: &str, temp_dir: &TempDir, target_url: &str) -> Result<PathBuf> {
339-
log::trace!("Trying to get tar file for plugin '{name}' from {target_url}");
338+
tracing::trace!("Trying to get tar file for plugin '{name}' from {target_url}");
340339
let plugin_bin = reqwest::get(target_url).await?;
341340
if !plugin_bin.status().is_success() {
342341
match plugin_bin.status() {
@@ -358,7 +357,7 @@ fn verify_checksum(plugin_file: &Path, expected_sha256: &str) -> Result<()> {
358357
let actual_sha256 = sha256::hex_digest_from_file(plugin_file)
359358
.with_context(|| format!("Cannot get digest for {}", plugin_file.display()))?;
360359
if actual_sha256 == expected_sha256 {
361-
log::info!("Package checksum verified successfully");
360+
tracing::info!("Package checksum verified successfully");
362361
Ok(())
363362
} else {
364363
Err(anyhow!("Checksum did not match, aborting installation."))

crates/plugins/src/store.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::{
77
path::{Path, PathBuf},
88
};
99
use tar::Archive;
10-
use tracing::log;
1110

1211
use crate::{error::*, manifest::PluginManifest};
1312

@@ -131,7 +130,7 @@ impl PluginStore {
131130
/// Looks up and parses the JSON plugin manifest file into object form.
132131
pub fn read_plugin_manifest(&self, plugin_name: &str) -> PluginLookupResult<PluginManifest> {
133132
let manifest_path = self.installed_manifest_path(plugin_name);
134-
log::info!("Reading plugin manifest from {}", manifest_path.display());
133+
tracing::info!("Reading plugin manifest from {}", manifest_path.display());
135134
let manifest_file = File::open(manifest_path.clone()).map_err(|e| {
136135
Error::NotFound(NotFoundError::new(
137136
Some(plugin_name.to_string()),
@@ -156,7 +155,7 @@ impl PluginStore {
156155
&File::create(self.installed_manifest_path(&plugin_manifest.name()))?,
157156
plugin_manifest,
158157
)?;
159-
log::trace!("Added manifest for {}", &plugin_manifest.name());
158+
tracing::trace!("Added manifest for {}", &plugin_manifest.name());
160159
Ok(())
161160
}
162161

crates/trigger-http/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ impl OutboundWasiHttpHandler for HttpRuntimeData {
692692
.allowed_hosts
693693
.allows(&OutboundUrl::parse(uri_string, "https")?);
694694
if unallowed_relative || unallowed_absolute {
695-
tracing::log::error!("Destination not allowed: {}", request.request.uri());
695+
tracing::error!("Destination not allowed: {}", request.request.uri());
696696
let host = if unallowed_absolute {
697697
// Safe to unwrap because absolute urls have a host by definition.
698698
let host = uri.authority().map(|a| a.host()).unwrap();

crates/trigger/src/runtime_config/llm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) async fn build_component(
2626
spin_llm::LlmComponent::new(move || Box::new(noop::NoopLlmEngine.clone()))
2727
}
2828
LlmComputeOpts::RemoteHttp(config) => {
29-
tracing::log::info!("Using remote compute for LLMs");
29+
tracing::info!("Using remote compute for LLMs");
3030
let engine =
3131
RemoteHttpLlmEngine::new(config.url.to_owned(), config.auth_token.to_owned());
3232
spin_llm::LlmComponent::new(move || Box::new(engine.clone()))

src/commands/external.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use spin_plugins::{
1010
use std::io::{stderr, IsTerminal};
1111
use std::{collections::HashMap, env, process};
1212
use tokio::process::Command;
13-
use tracing::log;
1413

1514
const BADGER_GRACE_PERIOD_MILLIS: u64 = 50;
1615

@@ -83,12 +82,12 @@ pub async fn execute_external_subcommand(
8382

8483
let badger = BadgerChecker::start(&plugin_name, plugin_version, SPIN_VERSION);
8584

86-
log::info!("Executing command {:?}", command);
85+
tracing::info!("Executing command {:?}", command);
8786
// Allow user to interact with stdio/stdout of child process
8887
let mut child = command.spawn()?;
8988
set_kill_on_ctrl_c(&child);
9089
let status = child.wait().await?;
91-
log::info!("Exiting process with {}", status);
90+
tracing::info!("Exiting process with {}", status);
9291

9392
report_badger_result(badger).await;
9493

0 commit comments

Comments
 (0)