Skip to content

Commit ca36ce8

Browse files
committed
Replace log with tracing in spin-redis
Signed-off-by: Lann Martin <lann.martin@fermyon.com>
1 parent 59a1ae5 commit ca36ce8

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/redis/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ doctest = false
1111
anyhow = "1.0"
1212
async-trait = "0.1"
1313
futures = "0.3"
14-
log = { version = "0.4", default-features = false }
1514
spin-engine = { path = "../engine" }
1615
spin-manifest = { path = "../manifest" }
1716
spin-trigger = { path = "../trigger" }

crates/redis/src/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
33
mod spin;
44

5-
use crate::spin::SpinRedisExecutor;
5+
use std::{collections::HashMap, sync::Arc};
6+
67
use anyhow::Result;
78
use async_trait::async_trait;
89
use futures::StreamExt;
910
use redis::{Client, ConnectionLike};
1011
use spin_manifest::{ComponentMap, RedisConfig, RedisTriggerConfiguration, TriggerConfig};
1112
use spin_redis::SpinRedisData;
1213
use spin_trigger::{cli::NoArgs, TriggerExecutor};
13-
use std::{collections::HashMap, sync::Arc};
14+
15+
use crate::spin::SpinRedisExecutor;
1416

1517
wit_bindgen_wasmtime::import!({paths: ["../../wit/ephemeral/spin-redis.wit"], async: *});
1618

@@ -80,14 +82,14 @@ impl TriggerExecutor for RedisTrigger {
8082
async fn run(self, _config: Self::RunConfig) -> Result<()> {
8183
let address = self.trigger_config.address.as_str();
8284

83-
log::info!("Connecting to Redis server at {}", address);
85+
tracing::info!("Connecting to Redis server at {}", address);
8486
let mut client = Client::open(address.to_string())?;
8587
let mut pubsub = client.get_async_connection().await?.into_pubsub();
8688

8789
// Subscribe to channels
8890
for (subscription, idx) in self.subscriptions.iter() {
8991
let name = &self.engine.config.components[*idx].id;
90-
log::info!(
92+
tracing::info!(
9193
"Subscribed component #{} ({}) to channel: {}",
9294
idx,
9395
name,
@@ -101,9 +103,9 @@ impl TriggerExecutor for RedisTrigger {
101103
match stream.next().await {
102104
Some(msg) => drop(self.handle(msg).await),
103105
None => {
104-
log::trace!("Empty message");
106+
tracing::trace!("Empty message");
105107
if !client.check_connection() {
106-
log::info!("No Redis connection available");
108+
tracing::info!("No Redis connection available");
107109
break Ok(());
108110
}
109111
}
@@ -116,7 +118,7 @@ impl RedisTrigger {
116118
// Handle the message.
117119
async fn handle(&self, msg: redis::Msg) -> Result<()> {
118120
let channel = msg.get_channel_name();
119-
log::info!("Received message on channel {:?}", channel);
121+
tracing::info!("Received message on channel {:?}", channel);
120122

121123
if let Some(idx) = self.subscriptions.get(channel).copied() {
122124
let component = &self.engine.config.components[idx];
@@ -134,7 +136,7 @@ impl RedisTrigger {
134136

135137
match executor {
136138
spin_manifest::RedisExecutor::Spin => {
137-
log::trace!("Executing Spin Redis component {}", component.id);
139+
tracing::trace!("Executing Spin Redis component {}", component.id);
138140
let executor = SpinRedisExecutor;
139141
executor
140142
.execute(
@@ -148,7 +150,7 @@ impl RedisTrigger {
148150
}
149151
};
150152
} else {
151-
log::debug!("No subscription found for {:?}", channel);
153+
tracing::debug!("No subscription found for {:?}", channel);
152154
}
153155

154156
Ok(())

crates/redis/src/spin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl RedisExecutor for SpinRedisExecutor {
1717
payload: &[u8],
1818
follow: bool,
1919
) -> Result<()> {
20-
log::trace!(
20+
tracing::trace!(
2121
"Executing request using the Spin executor for component {}",
2222
component
2323
);
@@ -30,11 +30,11 @@ impl RedisExecutor for SpinRedisExecutor {
3030

3131
let result = match Self::execute_impl(store, instance, channel, payload.to_vec()).await {
3232
Ok(()) => {
33-
log::trace!("Request finished OK");
33+
tracing::trace!("Request finished OK");
3434
Ok(())
3535
}
3636
Err(e) => {
37-
log::trace!("Request finished with error {}", e);
37+
tracing::trace!("Request finished with error {}", e);
3838
Err(e)
3939
}
4040
};

0 commit comments

Comments
 (0)