feat: log rotation (#5561)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use super::base::Usage;
|
||||
use super::errors::GoogleErrorCode;
|
||||
use crate::config::paths::Paths;
|
||||
use crate::model::ModelConfig;
|
||||
use crate::providers::errors::{OpenAIError, ProviderError};
|
||||
use anyhow::{anyhow, Result};
|
||||
@@ -471,8 +470,7 @@ impl RequestLog {
|
||||
where
|
||||
Payload: Serialize,
|
||||
{
|
||||
let logs_dir = Paths::in_state_dir("logs");
|
||||
std::fs::create_dir_all(&logs_dir)?;
|
||||
let logs_dir = crate::logging::prepare_log_directory("llm", true)?;
|
||||
|
||||
let request_id = Uuid::new_v4();
|
||||
let temp_name = format!("llm_request.{request_id}.jsonl");
|
||||
@@ -529,7 +527,7 @@ impl RequestLog {
|
||||
fn finish(&mut self) -> Result<()> {
|
||||
if let Some(mut writer) = self.writer.take() {
|
||||
writer.flush()?;
|
||||
let logs_dir = Paths::in_state_dir("logs");
|
||||
let logs_dir = crate::logging::prepare_log_directory("llm", true)?;
|
||||
let log_path = |i| logs_dir.join(format!("llm_request.{}.jsonl", i));
|
||||
|
||||
for i in (0..LOGS_TO_KEEP - 1).rev() {
|
||||
|
||||
Reference in New Issue
Block a user