mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: initialize logs right after configurations (#708)
This commit is contained in:
parent
46516dab74
commit
aa8448677e
3 changed files with 11 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ use yazi_config::keymap::Key;
|
||||||
use yazi_core::input::InputMode;
|
use yazi_core::input::InputMode;
|
||||||
use yazi_shared::{emit, event::{Cmd, Event, NEED_RENDER}, term::Term, Layer};
|
use yazi_shared::{emit, event::{Cmd, Event, NEED_RENDER}, term::Term, Layer};
|
||||||
|
|
||||||
use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Router, Signals};
|
use crate::{lives::Lives, Ctx, Executor, Router, Signals};
|
||||||
|
|
||||||
pub(crate) struct App {
|
pub(crate) struct App {
|
||||||
pub(crate) cx: Ctx,
|
pub(crate) cx: Ctx,
|
||||||
|
|
@ -16,8 +16,6 @@ pub(crate) struct App {
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub(crate) async fn run() -> Result<()> {
|
pub(crate) async fn run() -> Result<()> {
|
||||||
Panic::install();
|
|
||||||
let _log = Logs::init()?;
|
|
||||||
let term = Term::start()?;
|
let term = Term::start()?;
|
||||||
let signals = Signals::start()?;
|
let signals = Signals::start()?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
use anyhow::{Context, Result};
|
|
||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_subscriber::{fmt, prelude::__tracing_subscriber_SubscriberExt, Registry};
|
use tracing_subscriber::{fmt, prelude::__tracing_subscriber_SubscriberExt, Registry};
|
||||||
use yazi_boot::BOOT;
|
use yazi_shared::{RoCell, Xdg};
|
||||||
|
|
||||||
|
static _GUARD: RoCell<WorkerGuard> = RoCell::new();
|
||||||
|
|
||||||
pub(super) struct Logs;
|
pub(super) struct Logs;
|
||||||
|
|
||||||
impl Logs {
|
impl Logs {
|
||||||
pub(super) fn init() -> Result<WorkerGuard> {
|
pub(super) fn start() {
|
||||||
let appender = tracing_appender::rolling::never(&BOOT.state_dir, "yazi.log");
|
let appender = tracing_appender::rolling::never(Xdg::state_dir().unwrap(), "yazi.log");
|
||||||
let (handle, guard) = tracing_appender::non_blocking(appender);
|
let (handle, guard) = tracing_appender::non_blocking(appender);
|
||||||
|
|
||||||
// let filter = EnvFilter::from_default_env();
|
// let filter = EnvFilter::from_default_env();
|
||||||
let subscriber = Registry::default().with(fmt::layer().pretty().with_writer(handle));
|
let subscriber = Registry::default().with(fmt::layer().pretty().with_writer(handle));
|
||||||
|
|
||||||
tracing::subscriber::set_global_default(subscriber)
|
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
|
||||||
.context("setting default subscriber failed")?;
|
|
||||||
|
|
||||||
Ok(guard)
|
_GUARD.init(guard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ use signals::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
Panic::install();
|
||||||
|
Logs::start();
|
||||||
|
|
||||||
_ = fdlimit::raise_fd_limit();
|
_ = fdlimit::raise_fd_limit();
|
||||||
// console_subscriber::init();
|
|
||||||
|
|
||||||
yazi_config::init();
|
yazi_config::init();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue