Skip to content

Commit 5d24685

Browse files
committed
refactor: update logging framework and imports 🔄
- replace log::trace with tracing::trace across modules - update Git import from git to repository module - combine separate author email and name tests into single test Signed-off-by: mingcheng <[email protected]>
1 parent 2f5d9bc commit 5d24685

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

src/message.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
* File Created: 2025-10-16 15:06:58
1010
*
1111
* Modified By: mingcheng <[email protected]>
12-
* Last Modified: 2025-10-16 15:25:14
12+
* Last Modified: 2025-10-16 15:46:26
1313
*/
1414

15-
use std::{error::Error, fmt::Display};
16-
17-
use log::trace;
18-
1915
use crate::repository::Git;
16+
use std::{error::Error, fmt::Display};
17+
use tracing::trace;
2018

2119
pub struct GitMessage {
2220
pub title: String,
@@ -51,6 +49,9 @@ impl GitMessage {
5149
content.push_str(&_m);
5250
}
5351

52+
trace!("the commit message is valid");
53+
trace!("title:\n{}", title.trim());
54+
trace!("content:\n{}", content);
5455
Ok(Self {
5556
title: title.trim().to_string(),
5657
content,

src/openai.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ impl OpenAI {
132132
.messages(message)
133133
.build()?;
134134

135+
// trace!("Request: {:?}", request);
136+
trace!("✨ Using model: {}", model_name);
137+
135138
let response = match self.client.chat().create(request).await {
136139
Ok(s) => s,
137140
Err(e) => return Err(e),
@@ -167,10 +170,9 @@ impl OpenAI {
167170

168171
#[cfg(test)]
169172
mod test {
170-
use tracing::error;
171-
172173
use super::*;
173-
use crate::git::Git;
174+
use crate::repository::Git;
175+
use tracing::error;
174176

175177
fn setup_repo() -> Result<Git, Box<dyn Error>> {
176178
let repo_path = std::env::var("TEST_REPO_PATH")

src/repository.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* File Created: 2025-10-16 15:07:05
1010
*
1111
* Modified By: mingcheng <[email protected]>
12-
* Last Modified: 2025-10-16 15:28:33
12+
* Last Modified: 2025-10-16 15:43:22
1313
*/
1414

1515
use git2::{Repository, RepositoryOpenFlags, Signature, StatusOptions};
16-
use log::trace;
1716
use std::error::Error;
1817
use std::fmt::{Display, Formatter};
1918
use std::path::Path;
19+
use tracing::trace;
2020

2121
use crate::message::GitMessage;
2222

@@ -199,29 +199,11 @@ mod tests {
199199
}
200200

201201
#[test]
202-
fn test_get_author_email() {
203-
let repo = setup();
204-
if repo.is_err() {
205-
error!("please specify the repository path");
206-
return;
207-
}
208-
209-
let email = repo.unwrap().get_author_email();
210-
assert!(email.is_ok());
211-
assert!(!email.unwrap().is_empty());
212-
}
213-
214-
#[test]
215-
fn test_get_author_name() {
216-
let repo = setup();
217-
if repo.is_err() {
218-
error!("please specify the repository path");
219-
return;
220-
}
221-
222-
let name = repo.unwrap().get_author_name();
223-
assert!(name.is_ok());
224-
assert!(!name.unwrap().is_empty());
202+
fn test_get_author() {
203+
let repo = setup().unwrap();
204+
let author = repo.get_author().unwrap();
205+
assert!(!author.name.is_empty());
206+
assert!(!author.email.is_empty());
225207
}
226208

227209
#[test]

0 commit comments

Comments
 (0)