@@ -49,7 +49,7 @@ const MC_TEMPLATE_REPO: &str = "metacontract/template";
49
49
async fn main ( ) -> Result < ( ) > {
50
50
// check if qdrant is running
51
51
if let Err ( e) = ensure_qdrant_via_docker ( ) {
52
- eprintln ! ( "{e}" ) ;
52
+ log :: error !( "{e}" ) ;
53
53
std:: process:: exit ( 1 ) ;
54
54
}
55
55
env_logger:: Builder :: from_env ( env_logger:: Env :: default ( ) . default_filter_or ( "trace" ) )
@@ -711,7 +711,7 @@ mod tests {
711
711
impl ReferenceService for MockReferenceService {
712
712
// index_sources implementation
713
713
async fn index_sources ( & self , sources : & [ DocumentSource ] ) -> Result < ( ) > {
714
- println ! (
714
+ log :: info !(
715
715
"MockReferenceService: index_sources called with {} sources" ,
716
716
sources. len( )
717
717
) ;
@@ -727,7 +727,7 @@ mod tests {
727
727
query : mc_mcp:: domain:: reference:: SearchQuery ,
728
728
_score_threshold : Option < f32 > ,
729
729
) -> Result < Vec < SearchResult > > {
730
- println ! (
730
+ log :: info !(
731
731
"MockReferenceService: search_documents called with query: {:?}" ,
732
732
query
733
733
) ;
@@ -1158,34 +1158,34 @@ fi
1158
1158
1159
1159
1160
1160
// --- Debug: Check if mock script file actually exists ---
1161
- println ! ( "Checking existence of: {}" , forge_script_on_mock_bin. display( ) ) ;
1161
+ log :: info !( "Checking existence of: {}" , forge_script_on_mock_bin. display( ) ) ;
1162
1162
if forge_script_on_mock_bin. exists ( ) {
1163
- println ! ( "Mock script file FOUND." ) ;
1163
+ log :: info !( "Mock script file FOUND." ) ;
1164
1164
1165
1165
// --- Add execute permission ---
1166
1166
#[ cfg( unix) ]
1167
1167
{
1168
1168
use std:: os:: unix:: fs:: PermissionsExt ;
1169
- println ! ( "Setting execute permission on mock script..." ) ;
1169
+ log :: info !( "Setting execute permission on mock script..." ) ;
1170
1170
let metadata = std:: fs:: metadata ( & forge_script_on_mock_bin) . expect ( "Failed to get metadata for mock script" ) ;
1171
1171
let mut perms = metadata. permissions ( ) ;
1172
1172
if perms. mode ( ) & 0o111 == 0 { // Check if execute bit is NOT set
1173
1173
perms. set_mode ( perms. mode ( ) | 0o111 ) ; // Add execute permission for user, group, others
1174
1174
std:: fs:: set_permissions ( & forge_script_on_mock_bin, perms) . expect ( "Failed to set permissions on mock script" ) ;
1175
- println ! ( "Execute permission set." ) ;
1175
+ log :: info !( "Execute permission set." ) ;
1176
1176
} else {
1177
- println ! ( "Execute permission already set." ) ;
1177
+ log :: info !( "Execute permission already set." ) ;
1178
1178
}
1179
1179
}
1180
1180
// --- End Add execute permission ---
1181
1181
1182
1182
} else {
1183
- println ! ( "Mock script file NOT FOUND!" ) ;
1183
+ log :: error !( "Mock script file NOT FOUND!" ) ;
1184
1184
// もし見つからなかったら、ls の結果も見てみる
1185
1185
let ls_output = std:: process:: Command :: new ( "ls" ) . arg ( "-al" ) . arg ( mock_bin_path. display ( ) . to_string ( ) ) . output ( ) ;
1186
1186
match ls_output {
1187
- Ok ( out) => println ! ( "ls -al {}:\n {}" , mock_bin_path. display( ) , String :: from_utf8_lossy( & out. stdout) ) ,
1188
- Err ( e) => println ! ( "Failed to run ls: {}" , e) ,
1187
+ Ok ( out) => log :: error !( "ls -al {}:\n {}" , mock_bin_path. display( ) , String :: from_utf8_lossy( & out. stdout) ) ,
1188
+ Err ( e) => log :: error !( "Failed to run ls: {}" , e) ,
1189
1189
}
1190
1190
}
1191
1191
// --- End Debug ---
@@ -1197,23 +1197,23 @@ fi
1197
1197
std:: env:: set_var ( "PATH" , format ! ( "{}:{}" , mock_bin_abs_path_str, original_path) ) ;
1198
1198
1199
1199
// --- Debugging: Check which forge is used and run mock script directly ---
1200
- println ! ( "--- Debug Info: test_mc_deploy_broadcast_success ---" ) ;
1200
+ log :: info !( "--- Debug Info: test_mc_deploy_broadcast_success ---" ) ;
1201
1201
let which_output = std:: process:: Command :: new ( "which" ) . arg ( "forge" ) . output ( ) . expect ( "Failed to run which forge" ) ;
1202
- println ! ( "which forge stdout: {}" , String :: from_utf8_lossy( & which_output. stdout) ) ;
1203
- println ! ( "which forge stderr: {}" , String :: from_utf8_lossy( & which_output. stderr) ) ;
1204
- println ! ( "which forge status: {:?}" , which_output. status. code( ) ) ;
1202
+ log :: info !( "which forge stdout: {}" , String :: from_utf8_lossy( & which_output. stdout) ) ;
1203
+ log :: info !( "which forge stderr: {}" , String :: from_utf8_lossy( & which_output. stderr) ) ;
1204
+ log :: info !( "which forge status: {:?}" , which_output. status. code( ) ) ;
1205
1205
1206
- println ! ( "Executing mock script directly: {} script {} --broadcast" , forge_script_path_mock_abs. display( ) , expected_script_path) ;
1206
+ log :: info !( "Executing mock script directly: {} script {} --broadcast" , forge_script_path_mock_abs. display( ) , expected_script_path) ;
1207
1207
let mock_run_output = std:: process:: Command :: new ( forge_script_path_mock_abs)
1208
1208
. arg ( "script" )
1209
1209
. arg ( expected_script_path)
1210
1210
. arg ( "--broadcast" )
1211
1211
. output ( )
1212
1212
. expect ( "Failed to run mock forge script directly" ) ;
1213
- println ! ( "Mock script stdout: {}" , String :: from_utf8_lossy( & mock_run_output. stdout) ) ;
1214
- println ! ( "Mock script stderr: {}" , String :: from_utf8_lossy( & mock_run_output. stderr) ) ;
1215
- println ! ( "Mock script status: {:?}" , mock_run_output. status. code( ) ) ;
1216
- println ! ( "--- End Debug Info ---" ) ;
1213
+ log :: info !( "Mock script stdout: {}" , String :: from_utf8_lossy( & mock_run_output. stdout) ) ;
1214
+ log :: info !( "Mock script stderr: {}" , String :: from_utf8_lossy( & mock_run_output. stderr) ) ;
1215
+ log :: info !( "Mock script status: {:?}" , mock_run_output. status. code( ) ) ;
1216
+ log :: info !( "--- End Debug Info ---" ) ;
1217
1217
// --- End Debugging ---
1218
1218
1219
1219
let args = McDeployArgs {
@@ -1531,34 +1531,34 @@ fi
1531
1531
1532
1532
1533
1533
// --- Debug: Check if mock script file actually exists ---
1534
- println ! ( "Checking existence of: {}" , forge_script_on_mock_bin. display( ) ) ;
1534
+ log :: info !( "Checking existence of: {}" , forge_script_on_mock_bin. display( ) ) ;
1535
1535
if forge_script_on_mock_bin. exists ( ) {
1536
- println ! ( "Mock script file FOUND." ) ;
1536
+ log :: info !( "Mock script file FOUND." ) ;
1537
1537
1538
1538
// --- Add execute permission ---
1539
1539
#[ cfg( unix) ]
1540
1540
{
1541
1541
use std:: os:: unix:: fs:: PermissionsExt ;
1542
- println ! ( "Setting execute permission on mock script..." ) ;
1542
+ log :: info !( "Setting execute permission on mock script..." ) ;
1543
1543
let metadata = std:: fs:: metadata ( & forge_script_on_mock_bin) . expect ( "Failed to get metadata for mock script" ) ;
1544
1544
let mut perms = metadata. permissions ( ) ;
1545
1545
if perms. mode ( ) & 0o111 == 0 { // Check if execute bit is NOT set
1546
1546
perms. set_mode ( perms. mode ( ) | 0o111 ) ; // Add execute permission for user, group, others
1547
1547
std:: fs:: set_permissions ( & forge_script_on_mock_bin, perms) . expect ( "Failed to set permissions on mock script" ) ;
1548
- println ! ( "Execute permission set." ) ;
1548
+ log :: info !( "Execute permission set." ) ;
1549
1549
} else {
1550
- println ! ( "Execute permission already set." ) ;
1550
+ log :: info !( "Execute permission already set." ) ;
1551
1551
}
1552
1552
}
1553
1553
// --- End Add execute permission ---
1554
1554
1555
1555
} else {
1556
- println ! ( "Mock script file NOT FOUND!" ) ;
1556
+ log :: error !( "Mock script file NOT FOUND!" ) ;
1557
1557
// もし見つからなかったら、ls の結果も見てみる
1558
1558
let ls_output = std:: process:: Command :: new ( "ls" ) . arg ( "-al" ) . arg ( mock_bin_path. display ( ) . to_string ( ) ) . output ( ) ;
1559
1559
match ls_output {
1560
- Ok ( out) => println ! ( "ls -al {}:\n {}" , mock_bin_path. display( ) , String :: from_utf8_lossy( & out. stdout) ) ,
1561
- Err ( e) => println ! ( "Failed to run ls: {}" , e) ,
1560
+ Ok ( out) => log :: error !( "ls -al {}:\n {}" , mock_bin_path. display( ) , String :: from_utf8_lossy( & out. stdout) ) ,
1561
+ Err ( e) => log :: error !( "Failed to run ls: {}" , e) ,
1562
1562
}
1563
1563
}
1564
1564
// --- End Debug ---
@@ -1570,23 +1570,23 @@ fi
1570
1570
std:: env:: set_var ( "PATH" , format ! ( "{}:{}" , mock_bin_abs_path_str, original_path) ) ;
1571
1571
1572
1572
// --- Debugging: Check which forge is used and run mock script directly ---
1573
- println ! ( "--- Debug Info: test_mc_upgrade_broadcast_success ---" ) ;
1573
+ log :: info !( "--- Debug Info: test_mc_upgrade_broadcast_success ---" ) ;
1574
1574
let which_output = std:: process:: Command :: new ( "which" ) . arg ( "forge" ) . output ( ) . expect ( "Failed to run which forge" ) ;
1575
- println ! ( "which forge stdout: {}" , String :: from_utf8_lossy( & which_output. stdout) ) ;
1576
- println ! ( "which forge stderr: {}" , String :: from_utf8_lossy( & which_output. stderr) ) ;
1577
- println ! ( "which forge status: {:?}" , which_output. status. code( ) ) ;
1575
+ log :: info !( "which forge stdout: {}" , String :: from_utf8_lossy( & which_output. stdout) ) ;
1576
+ log :: info !( "which forge stderr: {}" , String :: from_utf8_lossy( & which_output. stderr) ) ;
1577
+ log :: info !( "which forge status: {:?}" , which_output. status. code( ) ) ;
1578
1578
1579
- println ! ( "Executing mock script directly: {} script {} --broadcast" , forge_script_path_mock_abs. display( ) , expected_script_path) ;
1579
+ log :: info !( "Executing mock script directly: {} script {} --broadcast" , forge_script_path_mock_abs. display( ) , expected_script_path) ;
1580
1580
let mock_run_output = std:: process:: Command :: new ( forge_script_path_mock_abs)
1581
1581
. arg ( "script" )
1582
1582
. arg ( expected_script_path)
1583
1583
. arg ( "--broadcast" )
1584
1584
. output ( )
1585
1585
. expect ( "Failed to run mock forge script directly" ) ;
1586
- println ! ( "Mock script stdout: {}" , String :: from_utf8_lossy( & mock_run_output. stdout) ) ;
1587
- println ! ( "Mock script stderr: {}" , String :: from_utf8_lossy( & mock_run_output. stderr) ) ;
1588
- println ! ( "Mock script status: {:?}" , mock_run_output. status. code( ) ) ;
1589
- println ! ( "--- End Debug Info ---" ) ;
1586
+ log :: info !( "Mock script stdout: {}" , String :: from_utf8_lossy( & mock_run_output. stdout) ) ;
1587
+ log :: info !( "Mock script stderr: {}" , String :: from_utf8_lossy( & mock_run_output. stderr) ) ;
1588
+ log :: info !( "Mock script status: {:?}" , mock_run_output. status. code( ) ) ;
1589
+ log :: info !( "--- End Debug Info ---" ) ;
1590
1590
// --- End Debugging ---
1591
1591
1592
1592
let args = McUpgradeArgs { broadcast : Some ( true ) } ;
@@ -1754,10 +1754,10 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
1754
1754
. map_err ( |e| format ! ( "Failed to execute docker ps: {e}" ) ) ?;
1755
1755
let ps_stdout = String :: from_utf8_lossy ( & ps. stdout ) ;
1756
1756
if ps_stdout. contains ( "qdrant" ) {
1757
- eprintln ! ( "✅ Qdrant is already running in Docker." ) ;
1757
+ log :: info !( "✅ Qdrant is already running in Docker." ) ;
1758
1758
} else {
1759
1759
// 3. Start Qdrant container
1760
- eprintln ! ( "Qdrant container not found. Starting Qdrant in Docker..." ) ;
1760
+ log :: info !( "Qdrant container not found. Starting Qdrant in Docker..." ) ;
1761
1761
let run = std:: process:: Command :: new ( "docker" )
1762
1762
. args ( [
1763
1763
"run" ,
@@ -1778,7 +1778,7 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
1778
1778
String :: from_utf8_lossy( & run. stderr)
1779
1779
) ) ;
1780
1780
}
1781
- eprintln ! ( "Qdrant container started." ) ;
1781
+ log :: info !( "Qdrant container started." ) ;
1782
1782
}
1783
1783
1784
1784
// 4. Health check (HTTP endpoint retry)
@@ -1789,12 +1789,12 @@ fn ensure_qdrant_via_docker() -> Result<(), String> {
1789
1789
. call ( )
1790
1790
{
1791
1791
Ok ( resp) if resp. status ( ) == 200 => {
1792
- eprintln ! ( "✅ Qdrant is running and connected!" ) ;
1792
+ log :: info !( "✅ Qdrant is running and connected!" ) ;
1793
1793
return Ok ( ( ) ) ;
1794
1794
}
1795
1795
_ => {
1796
- eprintln ! ( "Waiting for Qdrant to start... (Retry {i}/5)" ) ;
1797
- sleep ( Duration :: from_secs ( 2 ) ) ;
1796
+ log :: info !( "Waiting for Qdrant to start... (Retry {i}/5)" ) ;
1797
+ std :: thread :: sleep ( std :: time :: Duration :: from_secs ( 2 ) ) ;
1798
1798
}
1799
1799
}
1800
1800
}
0 commit comments