Skip to content

Commit

Permalink
chore: resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Phoeniix Zhao <[email protected]>
  • Loading branch information
Phoenix500526 committed Jun 7, 2024
1 parent ffb72f8 commit 89a687b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ pub mod rotation_format {
#[must_use]
#[inline]
pub const fn default_rotation() -> RotationConfig {
RotationConfig::Daily
RotationConfig::Never
}

/// Generates a `RollingFileAppender` from the given `RotationConfig` and `name`
Expand Down
4 changes: 2 additions & 2 deletions crates/utils/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ pub fn parse_log_file(s: &str) -> Result<PathBuf, ConfigParseError> {
// Explanation of the regex pattern:
// ^(\.|\.\.|~)? - Matches an optional prefix consisting of a dot (.), two dots (..), or a tilde (~).
// (/[a-zA-Z0-9._-]+)+/? - Matches one or more occurrences of a forward slash (/) followed by one or more alphanumeric characters, dots (.), underscores (_), or hyphens (-).
// /?$ - Matches an optional trailing forward slash (/) at the end of the string. // Overall, this regex pattern is used to validate file paths that follow
// a specific format commonly used in systems like Cargo in Rust.
// /?$ - Matches an optional trailing forward slash (/) at the end of the string.
// Overall, this regex pattern is used to validate file paths that follow a specific format commonly used in Linux filesystem
let re = Regex::new(r"^(\.|\.\.|~)?(/[a-zA-Z0-9._-]+)+/?$").unwrap_or_else(|err| {
unreachable!(
r"regex expression (^(\.|\.\.|~)?(/[a-zA-Z0-9._-]+)+/?$) should not return Error: {}",
Expand Down
4 changes: 2 additions & 2 deletions crates/xline/src/utils/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use opentelemetry_sdk::runtime::Tokio;
use tracing::warn;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::{fmt::format, layer::SubscriberExt, util::SubscriberInitExt, Layer};
use utils::config::{default_rotation, file_appender, LogConfig, TraceConfig};
use utils::config::{file_appender, LogConfig, RotationConfig, TraceConfig};

/// Return a Box trait from the config
fn generate_writer(name: &str, log_config: &LogConfig) -> Box<dyn std::io::Write + Send> {
if let Some(ref file_path) = *log_config.path() {
Box::new(file_appender(*log_config.rotation(), file_path, name))
} else {
if *log_config.rotation() != default_rotation() {
if matches!(*log_config.rotation(), RotationConfig::Never) {
warn!("The log is output to the terminal, so the rotation parameter is ignored.");
}
Box::new(std::io::stdout())
Expand Down
12 changes: 5 additions & 7 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ function common::run_xline() {
fi

if [ -n "$RUST_LOG" ]; then
docker_cmd="docker run -e RUST_LOG=${RUST_LOG} -d -it --rm --name=node${ith} --net=xline_net \
--ip=${SERVERS[$ith]} --cap-add=NET_ADMIN --cpu-shares=1024 \
-m=512M ${mount_point} ${XLINE_IMAGE} ${cmd}"
else
docker_cmd="docker run -d -it --rm --name=node${ith} --net=xline_net \
--ip=${SERVERS[$ith]} --cap-add=NET_ADMIN --cpu-shares=1024 \
-m=512M ${mount_point} ${XLINE_IMAGE} ${cmd}"
debug_env="-e RUST_LOG=${RUST_LOG}"
fi

docker_cmd="docker run ${debug_env} -d -it --rm --name=node${ith} --net=xline_net \
--ip=${SERVERS[$ith]} --cap-add=NET_ADMIN --cpu-shares=1024 \
-m=512M ${mount_point} ${XLINE_IMAGE} ${cmd}"

eval ${docker_cmd}
wait $!

Expand Down

0 comments on commit 89a687b

Please sign in to comment.