mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-05 02:55:31 +00:00
handle logger thread in main function
This commit is contained in:
parent
25d7d3d870
commit
c56978d1e7
@ -18,7 +18,7 @@ use crate::{
|
||||
list::ListOptions,
|
||||
utils::{
|
||||
self,
|
||||
logger::{info_accessible, spawn_logger_thread, warning},
|
||||
logger::{info_accessible, warning},
|
||||
to_utf, EscapedPathDisplay, FileVisibilityPolicy,
|
||||
},
|
||||
CliArgs, QuestionPolicy,
|
||||
@ -52,18 +52,6 @@ pub fn run(
|
||||
args: CliArgs,
|
||||
question_policy: QuestionPolicy,
|
||||
file_visibility_policy: FileVisibilityPolicy,
|
||||
) -> crate::Result<()> {
|
||||
let handler = spawn_logger_thread();
|
||||
run_cmd(args, question_policy, file_visibility_policy)?;
|
||||
handler.shutdown_and_wait();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_cmd(
|
||||
args: CliArgs,
|
||||
question_policy: QuestionPolicy,
|
||||
file_visibility_policy: FileVisibilityPolicy,
|
||||
) -> crate::Result<()> {
|
||||
match args.cmd {
|
||||
Subcommand::Compress {
|
||||
|
@ -18,6 +18,8 @@ use error::{Error, Result};
|
||||
use once_cell::sync::Lazy;
|
||||
use utils::{QuestionAction, QuestionPolicy};
|
||||
|
||||
use crate::utils::logger::spawn_logger_thread;
|
||||
|
||||
// Used in BufReader and BufWriter to perform less syscalls
|
||||
const BUFFER_CAPACITY: usize = 1024 * 32;
|
||||
|
||||
@ -28,7 +30,11 @@ static CURRENT_DIRECTORY: Lazy<PathBuf> = Lazy::new(|| env::current_dir().unwrap
|
||||
pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
|
||||
|
||||
fn main() {
|
||||
if let Err(err) = run() {
|
||||
let handler = spawn_logger_thread();
|
||||
let result = run();
|
||||
handler.shutdown_and_wait();
|
||||
|
||||
if let Err(err) = result {
|
||||
eprintln!("{err}");
|
||||
std::process::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user