Squashed commit of the following:
commit 2a9f2f20e9c6d88c2f96fd40589740e1f236f64a
Author: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon Oct 13 11:07:31 2025 +0800
fix: improve message handling in CommandEvent logging with CompactString
commit c77fc18accefeaf471594035d61bd13e235c87d6
Author: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon Oct 13 10:47:16 2025 +0800
fix: optimize shared writer locking in CommandEvent handling
commit d5286ee5f1612f17b7a97eead84d430669816d98
Author: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon Oct 13 10:30:19 2025 +0800
feat: integrate CompactString for improved logging and dependency management
commit 951fb2b120ce159c00dc57d43c5a519990f34cee
Author: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon Oct 13 09:39:29 2025 +0800
refactor: remove write_sidecar_log function and streamline logging in CommandEvent handling
commit fd48d66c55a2c62fd32741fd3c65cc06d4cc693f
Author: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon Oct 13 09:38:05 2025 +0800
Revert "refactor(core): stabilize 'static backing for sidecar logging"
This reverts commit fe7eb59f18.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
|
||||
use compact_str::CompactString;
|
||||
use once_cell::sync::OnceCell;
|
||||
use parking_lot::{RwLock, RwLockReadGuard};
|
||||
|
||||
const LOGS_QUEUE_LEN: usize = 100;
|
||||
|
||||
pub struct ClashLogger {
|
||||
logs: Arc<RwLock<VecDeque<String>>>,
|
||||
logs: Arc<RwLock<VecDeque<CompactString>>>,
|
||||
}
|
||||
|
||||
impl ClashLogger {
|
||||
@@ -18,11 +19,11 @@ impl ClashLogger {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_logs(&self) -> RwLockReadGuard<'_, VecDeque<String>> {
|
||||
pub fn get_logs(&self) -> RwLockReadGuard<'_, VecDeque<CompactString>> {
|
||||
self.logs.read()
|
||||
}
|
||||
|
||||
pub fn append_log(&self, text: String) {
|
||||
pub fn append_log(&self, text: CompactString) {
|
||||
let mut logs = self.logs.write();
|
||||
if logs.len() > LOGS_QUEUE_LEN {
|
||||
logs.pop_front();
|
||||
|
||||
Reference in New Issue
Block a user