Skip to content

Commit

Permalink
Tweak log levels for some logs
Browse files Browse the repository at this point in the history
The principles behind the changes were:
- if there is an interaction with the outside (eg. upload/download) -
  INFO
- inter-actor messages and other communication - DEBUG
- message payloads (they can be very large and there's no reason to
  print them multiple times) - TRACE
- implementation-level event that should be of no concern to the user,
  isn't a lot of data, and should be called once or few times - DEBUG

Signed-off-by: Marcel Guzik <[email protected]>
  • Loading branch information
Bravo555 committed Aug 21, 2023
1 parent f75238f commit a5a5ff9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion crates/common/download/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ async fn save_chunks_to_file_at(
writer.seek(SeekFrom::Start(offset))?;

while let Some(bytes) = response.chunk().await? {
debug!("read response chunk, size={size}", size = bytes.len());
writer.write_all(&bytes)?;
}
Ok(())
Expand Down
3 changes: 1 addition & 2 deletions crates/common/flockfile/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::path::Path;
use std::path::PathBuf;
use tracing::debug;
use tracing::error;
use tracing::info;
use tracing::warn;

const LOCK_CHILD_DIRECTORY: &str = "lock/";
Expand Down Expand Up @@ -100,7 +99,7 @@ impl Flockfile {
source: err,
})?;

info!(r#"Lockfile created {:?}"#, &path);
debug!(r#"Lockfile created {:?}"#, &path);
Ok(Flockfile {
handle: Some(file),
path,
Expand Down
12 changes: 6 additions & 6 deletions crates/core/tedge_actors/src/message_boxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ use crate::RuntimeRequest;
use async_trait::async_trait;
use futures::channel::mpsc;
use futures::StreamExt;
use log::info;
use log::debug;
use std::fmt::Debug;

/// Either a message or a [RuntimeRequest]
Expand Down Expand Up @@ -184,25 +184,25 @@ impl<Input: Debug> LoggingReceiver<Input> {
impl<Input: Send + Debug> MessageReceiver<Input> for LoggingReceiver<Input> {
async fn try_recv(&mut self) -> Result<Option<Input>, RuntimeRequest> {
let message = self.receiver.try_recv().await;
info!(target: &self.name, "recv {:?}", message);
debug!(target: &self.name, "recv {:?}", message);
message
}

async fn recv_message(&mut self) -> Option<WrappedInput<Input>> {
let message = self.receiver.recv_message().await;
info!(target: &self.name, "recv {:?}", message);
debug!(target: &self.name, "recv {:?}", message);
message
}

async fn recv(&mut self) -> Option<Input> {
let message = self.receiver.recv().await;
info!(target: &self.name, "recv {:?}", message);
debug!(target: &self.name, "recv {:?}", message);
message
}

async fn recv_signal(&mut self) -> Option<RuntimeRequest> {
let message = self.receiver.recv_signal().await;
info!(target: &self.name, "recv {:?}", message);
debug!(target: &self.name, "recv {:?}", message);
message
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ impl<Output: Debug + Send + Sync + 'static> Sender<Output> for LoggingSender<Out
}

pub fn log_message_sent<I: Debug>(target: &str, message: I) {
info!(target: target, "send {message:?}");
debug!(target: target, "send {message:?}");
}

/// The basic message box to send and receive messages
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_actors/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ where
for (running_as, sender) in a {
match sender.send(RuntimeRequest::Shutdown).await {
Ok(()) => {
info!(target: "Runtime", "Successfully sent shutdown request to {running_as}")
debug!(target: "Runtime", "Successfully sent shutdown request to {running_as}")
}
Err(e) => {
error!(target: "Runtime", "Failed to send shutdown request to {running_as}: {e:?}")
Expand Down
4 changes: 2 additions & 2 deletions crates/extensions/c8y_http_proxy/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl C8YHttpProxyActor {
.header("Content-Type", "text/plain")
.body(config_content.to_string()))
};
debug!(target: self.name(), "Uploading config file to URL: {}", self.end_point
info!(target: self.name(), "Uploading config file to URL: {}", self.end_point
.get_url_for_event_binary_upload(&event_response_id));
let http_result = self.execute(device_id.clone(), build_request).await??;

Expand Down Expand Up @@ -415,7 +415,7 @@ impl C8YHttpProxyActor {
download_info.auth = Some(Auth::new_bearer(token.as_str()));
}

debug!(target: self.name(), "Downloading from: {:?}", download_info.url());
info!(target: self.name(), "Downloading from: {:?}", download_info.url());
let downloader: Downloader =
Downloader::with_permission(request.file_path, request.file_permissions);
downloader.download(&download_info).await?;
Expand Down
5 changes: 4 additions & 1 deletion crates/extensions/c8y_log_manager/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use c8y_api::utils::bridge::is_c8y_bridge_up;
use c8y_http_proxy::handle::C8YHttpProxy;
use log::error;
use log::info;
use log::trace;
use log_manager::LogPluginConfig;
use tedge_actors::fan_in_message_type;
use tedge_actors::Actor;
Expand Down Expand Up @@ -66,7 +67,9 @@ impl LogManagerActor {
for smartrest_message in payload.split('\n') {
let result = match smartrest_message.split(',').next().unwrap_or_default() {
"522" => {
info!("Log request received: {payload}");
let topic = &message.topic.name;
info!("Log request received on topic: {topic}");
trace!("payload: {payload}");
match get_smartrest_device_id(payload) {
Some(device_id) if device_id == self.config.device_id => {
// retrieve smartrest object from payload
Expand Down

0 comments on commit a5a5ff9

Please sign in to comment.