Skip to content

Commit

Permalink
feat: Replace log with tracing
Browse files Browse the repository at this point in the history
Replaces `log` with `tracing` and the custom logger with
`tracing_subscriber::Fmt`.

Adding support for re-configuring the logger at run-time and
removing the old logger format.

Signed-off-by: Jonathan Woollett-Light <[email protected]>
  • Loading branch information
Jonathan Woollett-Light committed Aug 17, 2023
1 parent 99c6292 commit ca449f1
Show file tree
Hide file tree
Showing 24 changed files with 651 additions and 2,126 deletions.
151 changes: 139 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/api_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ mmds = { path = "../mmds" }
seccompiler = { path = "../seccompiler" }
utils = { path = "../utils" }
vmm = { path = "../vmm" }
tracing = "0.1.37"

[dev-dependencies]
libc = "0.2.117"
log = "0.4.19"
4 changes: 2 additions & 2 deletions src/api_server/src/parsed_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::fmt::Debug;

use logger::{error, info, log_enabled, Level};
use logger::{error, info, Level};
use micro_http::{Body, Method, Request, Response, StatusCode, Version};
use serde::ser::Serialize;
use serde_json::Value;
Expand Down Expand Up @@ -232,7 +232,7 @@ fn describe(method: Method, path: &str, body: Option<&Body>) -> String {
("/cpu-config", Some(payload_value)) => {
// If the log level is at Debug or higher, include the CPU template in
// the log line.
if log_enabled!(Level::Debug) {
if tracing::enabled!(Level::DEBUG) {
describe_with_body(method, path, payload_value)
} else {
format!(
Expand Down
Loading

0 comments on commit ca449f1

Please sign in to comment.