mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-27 04:01:11 +08:00
feat: OXIDE_LOG_FILE 环境变量启用按日滚动日志文件输出
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
//! 重建信号。
|
//! 重建信号。
|
||||||
|
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -34,8 +35,13 @@ pub struct KernelCore {
|
|||||||
impl KernelCore {
|
impl KernelCore {
|
||||||
/// 按配置创建共享核心:初始化日志系统与四个共享 forge(interner/shape/code/prop)。
|
/// 按配置创建共享核心:初始化日志系统与四个共享 forge(interner/shape/code/prop)。
|
||||||
pub fn new(config: KernelConfig) -> Arc<Self> {
|
pub fn new(config: KernelConfig) -> Arc<Self> {
|
||||||
|
// OXIDE_LOG_FILE 指向目录时日志按日滚动落盘该目录(同镜像 stderr),缺省仅 stderr。
|
||||||
|
let output = match std::env::var("OXIDE_LOG_FILE") {
|
||||||
|
Ok(dir) if !dir.is_empty() => oxide_log::Output::File(PathBuf::from(dir)),
|
||||||
|
_ => oxide_log::Output::Stderr,
|
||||||
|
};
|
||||||
oxide_log::init(&oxide_log::LogConfig {
|
oxide_log::init(&oxide_log::LogConfig {
|
||||||
output: oxide_log::Output::Stderr,
|
output,
|
||||||
levels: config.log_levels,
|
levels: config.log_levels,
|
||||||
});
|
});
|
||||||
let perm_interner = Arc::new(PermInterner::new());
|
let perm_interner = Arc::new(PermInterner::new());
|
||||||
|
|||||||
@@ -95,8 +95,13 @@ fn run_tests() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
eprintln!("[LOG] level={log_level:?}");
|
eprintln!("[LOG] level={log_level:?}");
|
||||||
|
// OXIDE_LOG_FILE 指向目录时日志按日滚动落盘该目录(同镜像 stderr),缺省仅 stderr。
|
||||||
|
let output = match std::env::var("OXIDE_LOG_FILE") {
|
||||||
|
Ok(dir) if !dir.is_empty() => Output::File(PathBuf::from(dir)),
|
||||||
|
_ => Output::Stderr,
|
||||||
|
};
|
||||||
oxide_log::init(&LogConfig {
|
oxide_log::init(&LogConfig {
|
||||||
output: Output::Stderr,
|
output,
|
||||||
levels: [log_level; SUBSYSTEM_COUNT],
|
levels: [log_level; SUBSYSTEM_COUNT],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user