Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logger #4047

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
v1.4.0 are available as an improved iteration of the static CPU templates. For
more information about the transition from static CPU templates to custom CPU
templates, please refer to [this GitHub discussion](https://github.com/firecracker-microvm/firecracker/discussions/4135).

- Changed default log level from
[`Warn`](https://docs.rs/log/latest/log/enum.Level.html#variant.Warn) to
[`Info`](https://docs.rs/log/latest/log/enum.Level.html#variant.Info). This
results in more logs being output by default.
### Fixed

- Fixed a change in behavior of normalize host brand string that breaks
Expand Down
43 changes: 22 additions & 21 deletions src/api_server/src/request/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

use vmm::logger::{IncMetric, METRICS};
use vmm::vmm_config::logger_config::LoggerConfig;

use super::super::VmmAction;
use crate::parsed_request::{Error, ParsedRequest};
use crate::request::Body;

pub(crate) fn parse_put_logger(body: &Body) -> Result<ParsedRequest, Error> {
METRICS.put_api_requests.logger_count.inc();
let res = serde_json::from_slice::<LoggerConfig>(body.raw());
let res = serde_json::from_slice::<vmm::logger::LoggerConfig>(body.raw());
let config = res.map_err(|err| {
METRICS.put_api_requests.logger_fails.inc();
err
Expand All @@ -22,41 +21,43 @@ pub(crate) fn parse_put_logger(body: &Body) -> Result<ParsedRequest, Error> {
mod tests {
use std::path::PathBuf;

use vmm::vmm_config::logger_config::LoggerLevel;
use vmm::logger::{LevelFilter, LoggerConfig};

use super::*;
use crate::parsed_request::tests::vmm_action_from_request;

#[test]
fn test_parse_put_logger_request() {
let body = r#"{
"log_path": "log",
"level": "Warning",
"show_level": false,
"show_log_origin": false
}"#;
"log_path": "log",
"level": "Warning",
"show_level": false,
"show_log_origin": false
}"#;

let expected_config = LoggerConfig {
log_path: PathBuf::from("log"),
level: LoggerLevel::Warning,
show_level: false,
show_log_origin: false,
log_path: Some(PathBuf::from("log")),
level: Some(LevelFilter::Warn),
show_level: Some(false),
show_log_origin: Some(false),
};
assert_eq!(
vmm_action_from_request(parse_put_logger(&Body::new(body)).unwrap()),
VmmAction::ConfigureLogger(expected_config)
);

let body = r#"{
"log_path": "log",
"level": "DEBUG",
"show_level": false,
"show_log_origin": false
}"#;
"log_path": "log",
"level": "DEBUG",
"show_level": false,
"show_log_origin": false
}"#;

let expected_config = LoggerConfig {
log_path: PathBuf::from("log"),
level: LoggerLevel::Debug,
show_level: false,
show_log_origin: false,
log_path: Some(PathBuf::from("log")),
level: Some(LevelFilter::Debug),
show_level: Some(false),
show_log_origin: Some(false),
};
assert_eq!(
vmm_action_from_request(parse_put_logger(&Body::new(body)).unwrap()),
Expand Down
4 changes: 2 additions & 2 deletions src/api_server/swagger/firecracker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,8 @@ definitions:
level:
type: string
description: Set the level. The possible values are case-insensitive.
enum: [Error, Warning, Info, Debug]
default: Warning
enum: [Error, Warning, Info, Debug, Trace, Off]
default: Info
pb8o marked this conversation as resolved.
Show resolved Hide resolved
log_path:
type: string
description: Path to the named pipe or file for the human readable log output.
Expand Down
Loading