Skip to content

Commit 69b4359

Browse files
guvencMalteJ
authored andcommitted
Improve log output, non functional change
Signed-off-by: Guvenc Gulce <[email protected]>
1 parent 21a09d6 commit 69b4359

File tree

17 files changed

+260
-258
lines changed

17 files changed

+260
-258
lines changed

feos/services/host-service/src/api.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl HostService for HostApiHandler {
3535
&self,
3636
_request: Request<HostnameRequest>,
3737
) -> Result<Response<HostnameResponse>, Status> {
38-
info!("HOST_API_HANDLER: Received Hostname request.");
38+
info!("HostApi: Received Hostname request.");
3939
let (resp_tx, resp_rx) = oneshot::channel();
4040
let cmd = Command::GetHostname(resp_tx);
4141
self.dispatcher_tx
@@ -56,7 +56,7 @@ impl HostService for HostApiHandler {
5656
&self,
5757
_request: Request<MemoryRequest>,
5858
) -> Result<Response<MemoryResponse>, Status> {
59-
info!("HOST_API_HANDLER: Received GetMemory request.");
59+
info!("HostApi: Received GetMemory request.");
6060
let (resp_tx, resp_rx) = oneshot::channel();
6161
let cmd = Command::GetMemory(resp_tx);
6262
self.dispatcher_tx
@@ -77,7 +77,7 @@ impl HostService for HostApiHandler {
7777
&self,
7878
_request: Request<GetCpuInfoRequest>,
7979
) -> Result<Response<GetCpuInfoResponse>, Status> {
80-
info!("HOST_API_HANDLER: Received GetCPUInfo request.");
80+
info!("HostApi: Received GetCPUInfo request.");
8181
let (resp_tx, resp_rx) = oneshot::channel();
8282
let cmd = Command::GetCPUInfo(resp_tx);
8383
self.dispatcher_tx
@@ -98,7 +98,7 @@ impl HostService for HostApiHandler {
9898
&self,
9999
_request: Request<GetNetworkInfoRequest>,
100100
) -> Result<Response<GetNetworkInfoResponse>, Status> {
101-
info!("HOST_API_HANDLER: Received GetNetworkInfo request.");
101+
info!("HostApi: Received GetNetworkInfo request.");
102102
let (resp_tx, resp_rx) = oneshot::channel();
103103
let cmd = Command::GetNetworkInfo(resp_tx);
104104
self.dispatcher_tx
@@ -119,7 +119,7 @@ impl HostService for HostApiHandler {
119119
&self,
120120
request: Request<ShutdownRequest>,
121121
) -> Result<Response<ShutdownResponse>, Status> {
122-
info!("HOST_API_HANDLER: Received Shutdown request.");
122+
info!("HostApi: Received Shutdown request.");
123123
let (resp_tx, resp_rx) = oneshot::channel();
124124
let cmd = Command::Shutdown(request.into_inner(), resp_tx);
125125
self.dispatcher_tx
@@ -140,7 +140,7 @@ impl HostService for HostApiHandler {
140140
&self,
141141
request: Request<RebootRequest>,
142142
) -> Result<Response<RebootResponse>, Status> {
143-
info!("HOST_API_HANDLER: Received Reboot request.");
143+
info!("HostApi: Received Reboot request.");
144144
let (resp_tx, resp_rx) = oneshot::channel();
145145
let cmd = Command::Reboot(request.into_inner(), resp_tx);
146146
self.dispatcher_tx
@@ -161,7 +161,7 @@ impl HostService for HostApiHandler {
161161
&self,
162162
request: Request<UpgradeFeosBinaryRequest>,
163163
) -> Result<Response<UpgradeFeosBinaryResponse>, Status> {
164-
info!("HOST_API_HANDLER: Received UpgradeFeosBinary request.");
164+
info!("HostApi: Received UpgradeFeosBinary request.");
165165
let (resp_tx, resp_rx) = oneshot::channel();
166166
let cmd = Command::UpgradeFeosBinary(request.into_inner(), resp_tx);
167167
self.dispatcher_tx
@@ -182,7 +182,7 @@ impl HostService for HostApiHandler {
182182
&self,
183183
_request: Request<StreamKernelLogsRequest>,
184184
) -> Result<Response<Self::StreamKernelLogsStream>, Status> {
185-
info!("HOST_API_HANDLER: Received StreamKernelLogs request.");
185+
info!("HostApi: Received StreamKernelLogs request.");
186186
let (stream_tx, stream_rx) = mpsc::channel(128);
187187
let cmd = Command::StreamKernelLogs(stream_tx);
188188
self.dispatcher_tx
@@ -197,7 +197,7 @@ impl HostService for HostApiHandler {
197197
&self,
198198
_request: Request<StreamFeosLogsRequest>,
199199
) -> Result<Response<Self::StreamFeOSLogsStream>, Status> {
200-
info!("HOST_API_HANDLER: Received StreamFeOSLogs request.");
200+
info!("HostApi: Received StreamFeOSLogs request.");
201201
let (stream_tx, stream_rx) = mpsc::channel(128);
202202
let cmd = Command::StreamFeOSLogs(stream_tx);
203203
self.dispatcher_tx
@@ -212,7 +212,7 @@ impl HostService for HostApiHandler {
212212
&self,
213213
_request: Request<GetVersionInfoRequest>,
214214
) -> Result<Response<GetVersionInfoResponse>, Status> {
215-
info!("HOST_API_HANDLER: Received GetVersionInfo request.");
215+
info!("HostApi: Received GetVersionInfo request.");
216216
let (resp_tx, resp_rx) = oneshot::channel();
217217
let cmd = Command::GetVersionInfo(resp_tx);
218218
self.dispatcher_tx

feos/services/host-service/src/dispatcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl HostServiceDispatcher {
2626
}
2727

2828
pub async fn run(mut self) {
29-
info!("HOST_DISPATCHER: Running and waiting for commands.");
29+
info!("HostDispatcher: Running and waiting for commands.");
3030
while let Some(cmd) = self.rx.recv().await {
3131
match cmd {
3232
Command::GetHostname(responder) => {
@@ -63,6 +63,6 @@ impl HostServiceDispatcher {
6363
}
6464
}
6565
}
66-
info!("HOST_DISPATCHER: Channel closed, shutting down.");
66+
info!("HostDispatcher: Channel closed, shutting down.");
6767
}
6868
}

feos/services/host-service/src/worker/info.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use tokio::sync::oneshot;
1515
use tonic::Status;
1616

1717
pub async fn handle_hostname(responder: oneshot::Sender<Result<HostnameResponse, Status>>) {
18-
info!("HOST_WORKER: Processing Hostname request.");
18+
info!("HostWorker: Processing Hostname request.");
1919
let result = match unistd::gethostname() {
2020
Ok(host) => {
2121
let hostname = host
@@ -25,15 +25,13 @@ pub async fn handle_hostname(responder: oneshot::Sender<Result<HostnameResponse,
2525
}
2626
Err(e) => {
2727
let msg = format!("Failed to get system hostname: {e}");
28-
error!("HOST_WORKER: {msg}");
28+
error!("HostWorker: {msg}");
2929
Err(Status::internal(msg))
3030
}
3131
};
3232

3333
if responder.send(result).is_err() {
34-
error!(
35-
"HOST_WORKER: Failed to send response for Hostname. API handler may have timed out."
36-
);
34+
error!("HostWorker: Failed to send response for Hostname. API handler may have timed out.");
3735
}
3836
}
3937

@@ -114,20 +112,20 @@ async fn read_and_parse_meminfo() -> Result<MemInfo, std::io::Error> {
114112
}
115113

116114
pub async fn handle_get_memory(responder: oneshot::Sender<Result<MemoryResponse, Status>>) {
117-
info!("HOST_WORKER: Processing GetMemory request.");
115+
info!("HostWorker: Processing GetMemory request.");
118116
let result = match read_and_parse_meminfo().await {
119117
Ok(mem_info) => Ok(MemoryResponse {
120118
mem_info: Some(mem_info),
121119
}),
122120
Err(e) => {
123-
error!("HOST_WORKER: Failed to get memory info: {e}");
121+
error!("HostWorker: Failed to get memory info: {e}");
124122
Err(Status::internal(format!("Failed to get memory info: {e}")))
125123
}
126124
};
127125

128126
if responder.send(result).is_err() {
129127
error!(
130-
"HOST_WORKER: Failed to send response for GetMemory. API handler may have timed out."
128+
"HostWorker: Failed to send response for GetMemory. API handler may have timed out."
131129
);
132130
}
133131
}
@@ -207,18 +205,18 @@ async fn read_and_parse_cpuinfo() -> Result<Vec<CpuInfo>, std::io::Error> {
207205
}
208206

209207
pub async fn handle_get_cpu_info(responder: oneshot::Sender<Result<GetCpuInfoResponse, Status>>) {
210-
info!("HOST_WORKER: Processing GetCPUInfo request.");
208+
info!("HostWorker: Processing GetCPUInfo request.");
211209
let result = match read_and_parse_cpuinfo().await {
212210
Ok(cpu_info) => Ok(GetCpuInfoResponse { cpu_info }),
213211
Err(e) => {
214-
error!("HOST_WORKER: Failed to get CPU info: {e}");
212+
error!("HostWorker: Failed to get CPU info: {e}");
215213
Err(Status::internal(format!("Failed to get CPU info: {e}")))
216214
}
217215
};
218216

219217
if responder.send(result).is_err() {
220218
error!(
221-
"HOST_WORKER: Failed to send response for GetCPUInfo. API handler may have timed out."
219+
"HostWorker: Failed to send response for GetCPUInfo. API handler may have timed out."
222220
);
223221
}
224222
}
@@ -280,11 +278,11 @@ async fn read_all_net_stats() -> Result<Vec<NetDev>, std::io::Error> {
280278
pub async fn handle_get_network_info(
281279
responder: oneshot::Sender<Result<GetNetworkInfoResponse, Status>>,
282280
) {
283-
info!("HOST_WORKER: Processing GetNetworkInfo request.");
281+
info!("HostWorker: Processing GetNetworkInfo request.");
284282
let result = match read_all_net_stats().await {
285283
Ok(devices) => Ok(GetNetworkInfoResponse { devices }),
286284
Err(e) => {
287-
error!("HOST_WORKER: Failed to get network info: {e}");
285+
error!("HostWorker: Failed to get network info: {e}");
288286
Err(Status::internal(format!(
289287
"Failed to get network info from sysfs: {e}"
290288
)))
@@ -293,15 +291,15 @@ pub async fn handle_get_network_info(
293291

294292
if responder.send(result).is_err() {
295293
error!(
296-
"HOST_WORKER: Failed to send response for GetNetworkInfo. API handler may have timed out."
294+
"HostWorker: Failed to send response for GetNetworkInfo. API handler may have timed out."
297295
);
298296
}
299297
}
300298

301299
pub async fn handle_get_version_info(
302300
responder: oneshot::Sender<Result<GetVersionInfoResponse, Status>>,
303301
) {
304-
info!("HOST_WORKER: Processing GetVersionInfo request.");
302+
info!("HostWorker: Processing GetVersionInfo request.");
305303

306304
let kernel_version_res = fs::read_to_string("/proc/version").await;
307305

@@ -315,14 +313,14 @@ pub async fn handle_get_version_info(
315313
}
316314
Err(e) => {
317315
let msg = format!("Failed to read kernel version from /proc/version: {e}");
318-
error!("HOST_WORKER: {msg}");
316+
error!("HostWorker: {msg}");
319317
Err(Status::internal(msg))
320318
}
321319
};
322320

323321
if responder.send(result).is_err() {
324322
error!(
325-
"HOST_WORKER: Failed to send response for GetVersionInfo. API handler may have timed out."
323+
"HostWorker: Failed to send response for GetVersionInfo. API handler may have timed out."
326324
);
327325
}
328326
}

0 commit comments

Comments
 (0)