Reduce error log by downgrading unnecessary error!
to warn!
This commit is contained in:
parent
367fa9c4ce
commit
6c8c8fc871
@ -437,12 +437,12 @@ fn parse_host_files(file_buffer: *const host_file_buffer) -> Result<i32> {
|
|||||||
let resolv_conf_ptr = unsafe { (*file_buffer).resolv_conf_buf };
|
let resolv_conf_ptr = unsafe { (*file_buffer).resolv_conf_buf };
|
||||||
match parse_host_file(HostFile::ResolvConf, resolv_conf_ptr) {
|
match parse_host_file(HostFile::ResolvConf, resolv_conf_ptr) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("failed to parse /etc/resolv.conf: {}", e.backtrace());
|
warn!("failed to parse /etc/resolv.conf: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
Ok(resolv_conf_str) => {
|
Ok(resolv_conf_str) => {
|
||||||
*RESOLV_CONF_STR.write().unwrap() = Some(resolv_conf_str);
|
*RESOLV_CONF_STR.write().unwrap() = Some(resolv_conf_str);
|
||||||
if let Err(e) = write_host_file(HostFile::ResolvConf) {
|
if let Err(e) = write_host_file(HostFile::ResolvConf) {
|
||||||
error!("failed to write /etc/resolv.conf: {}", e.backtrace());
|
warn!("failed to write /etc/resolv.conf: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,13 +450,13 @@ fn parse_host_files(file_buffer: *const host_file_buffer) -> Result<i32> {
|
|||||||
let hostname_ptr = unsafe { (*file_buffer).hostname_buf };
|
let hostname_ptr = unsafe { (*file_buffer).hostname_buf };
|
||||||
match parse_host_file(HostFile::HostName, hostname_ptr) {
|
match parse_host_file(HostFile::HostName, hostname_ptr) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("failed to parse /etc/hostname: {}", e.backtrace());
|
warn!("failed to parse /etc/hostname: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
Ok(hostname_str) => {
|
Ok(hostname_str) => {
|
||||||
misc::init_nodename(&hostname_str);
|
misc::init_nodename(&hostname_str);
|
||||||
*HOSTNAME_STR.write().unwrap() = Some(hostname_str);
|
*HOSTNAME_STR.write().unwrap() = Some(hostname_str);
|
||||||
if let Err(e) = write_host_file(HostFile::HostName) {
|
if let Err(e) = write_host_file(HostFile::HostName) {
|
||||||
error!("failed to write /etc/hostname: {}", e.backtrace());
|
warn!("failed to write /etc/hostname: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,12 +464,12 @@ fn parse_host_files(file_buffer: *const host_file_buffer) -> Result<i32> {
|
|||||||
let hosts_ptr = unsafe { (*file_buffer).hosts_buf };
|
let hosts_ptr = unsafe { (*file_buffer).hosts_buf };
|
||||||
match parse_host_file(HostFile::Hosts, hosts_ptr) {
|
match parse_host_file(HostFile::Hosts, hosts_ptr) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("failed to parse /etc/hosts: {}", e.backtrace());
|
warn!("failed to parse /etc/hosts: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
Ok(hosts_str) => {
|
Ok(hosts_str) => {
|
||||||
*HOSTS_STR.write().unwrap() = Some(hosts_str);
|
*HOSTS_STR.write().unwrap() = Some(hosts_str);
|
||||||
if let Err(e) = write_host_file(HostFile::Hosts) {
|
if let Err(e) = write_host_file(HostFile::Hosts) {
|
||||||
error!("failed to write /etc/hosts: {}", e.backtrace());
|
warn!("failed to write /etc/hosts: {}", e.backtrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,26 +689,38 @@ fn do_syscall(user_context: &mut CpuContext) {
|
|||||||
let retval = match ret {
|
let retval = match ret {
|
||||||
Ok(retval) => retval as isize,
|
Ok(retval) => retval as isize,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let should_log_err = |errno| {
|
// let syscall_num = SyscallNum::try_from(num).unwrap();
|
||||||
|
let should_log_err = |num, errno| {
|
||||||
|
let syscall_num = match SyscallNum::try_from(num) {
|
||||||
|
Ok(num) => num,
|
||||||
|
Err(e) => return true,
|
||||||
|
};
|
||||||
// If the log level requires every detail, don't ignore any error
|
// If the log level requires every detail, don't ignore any error
|
||||||
if log::max_level() == LevelFilter::Trace {
|
if log::max_level() == LevelFilter::Trace {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other log levels require errors to be outputed. But
|
// All other log levels require errors to be outputed. But
|
||||||
// some errnos are usually benign and may occur in a very high
|
// some errnos are usually benign and may occur in a very high
|
||||||
// frequency. So we want to ignore them to keep noises at a
|
// frequency. So we want to lower them to warn level to keep noises
|
||||||
// minimum level in the log.
|
// at a minimum level in the error log.
|
||||||
//
|
//
|
||||||
// TODO: use a smarter, frequency-based strategy to decide whether
|
// TODO: use a smarter, frequency-based strategy to decide whether
|
||||||
// to suppress error messages.
|
// to suppress error messages.
|
||||||
match errno {
|
match errno {
|
||||||
EAGAIN | ETIMEDOUT => false,
|
EAGAIN | ETIMEDOUT | ENOENT | ENOTTY => false,
|
||||||
|
ENOSYS => match syscall_num {
|
||||||
|
SyscallNum::Getrusage => false,
|
||||||
|
SyscallNum::Madvise => false,
|
||||||
|
_ => true,
|
||||||
|
},
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if should_log_err(e.errno()) {
|
|
||||||
|
if should_log_err(num, e.errno()) {
|
||||||
error!("Error = {}", e.backtrace());
|
error!("Error = {}", e.backtrace());
|
||||||
|
} else {
|
||||||
|
warn!("Error = {}", e.backtrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
let retval = -(e.errno() as isize);
|
let retval = -(e.errno() as isize);
|
||||||
|
@ -485,10 +485,12 @@ impl ProcessVM {
|
|||||||
*brk_guard = brk;
|
*brk_guard = brk;
|
||||||
Ok(brk)
|
Ok(brk)
|
||||||
} else {
|
} else {
|
||||||
if brk < heap_start {
|
if brk == 0 {
|
||||||
error!("New brk address is too low");
|
debug!("Try get current program break address")
|
||||||
|
} else if brk < heap_start {
|
||||||
|
warn!("New brk address is too low");
|
||||||
} else if brk > heap_end {
|
} else if brk > heap_end {
|
||||||
error!("New brk address is too high");
|
warn!("New brk address is too high");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(*brk_guard)
|
Ok(*brk_guard)
|
||||||
|
Loading…
Reference in New Issue
Block a user