Append program name in log

This commit is contained in:
Wildan M
2026-02-13 20:23:29 +07:00
parent 31b674d6a6
commit 83a1680beb
2 changed files with 6 additions and 3 deletions
+5 -1
View File
@@ -2,7 +2,7 @@ use core::{fmt, str::FromStr};
use crate::{c_str::CStr, io::prelude::*, sync::Mutex};
use alloc::string::String;
use alloc::string::{String, ToString};
use log::{Metadata, Record};
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Info;
@@ -23,6 +23,10 @@ pub unsafe fn init() {
logger = logger.with_output(OutputBuilder::stderr().with_filter(level).build());
}
}
if let Some(name) = CStr::from_nullable_ptr(crate::platform::program_invocation_short_name)
{
logger = logger.with_process_name(name.to_str().unwrap_or("x").to_string());
}
}
if logger.enable().is_err() {
log::error!("Logger already initialized");
+1 -2
View File
@@ -115,7 +115,6 @@ extern "C" fn init_array() {
unsafe {
crate::pthread::init();
crate::platform::logger::init();
init_complete = true
}
}
@@ -218,8 +217,8 @@ pub unsafe extern "C" fn relibc_start_v1(
let auxvs = unsafe { get_auxvs(sp.auxv().cast()) };
unsafe { crate::platform::init(auxvs) };
init_array();
unsafe { crate::platform::logger::init() };
// Run preinit array
{