|
12 | 12 | use crate::{context::Context, utils::spawn_command}; |
13 | 13 | use fastcgi_client::{Client, Params, Request}; |
14 | 14 | use libc::{SIGTERM, atexit, kill, pid_t}; |
| 15 | +use log::debug; |
15 | 16 | use std::{ |
| 17 | + borrow::Cow, |
16 | 18 | fs, |
17 | 19 | path::Path, |
18 | 20 | process::Child, |
@@ -82,13 +84,11 @@ impl FpmHandle { |
82 | 84 | "-y", |
83 | 85 | &fpm_conf_file.path().display().to_string(), |
84 | 86 | ]; |
85 | | - eprintln!("===== setup php-fpm ====="); |
86 | | - eprintln!("{}", argv.join(" ")); |
| 87 | + debug!(argv:% = argv.join(" "); "setup php-fpm"); |
87 | 88 |
|
88 | 89 | let child = spawn_command(&argv, Some(Duration::from_secs(3))); |
89 | 90 | let log = fs::read_to_string("/tmp/.php-fpm.log").unwrap(); |
90 | | - eprintln!("===== php-fpm log ====="); |
91 | | - eprintln!("{}", log); |
| 91 | + debug!(log:%; "php-fpm log"); |
92 | 92 | // fs::remove_file("/tmp/.php-fpm.log").unwrap(); |
93 | 93 |
|
94 | 94 | let handle = FpmHandle { |
@@ -191,24 +191,16 @@ impl FpmHandle { |
191 | 191 |
|
192 | 192 | let no_error = stderr.is_empty(); |
193 | 193 |
|
194 | | - let f = |out: Vec<u8>| { |
195 | | - String::from_utf8(out) |
196 | | - .map(|out| { |
197 | | - if out.is_empty() { |
198 | | - "<empty>".to_owned() |
199 | | - } else { |
200 | | - out |
201 | | - } |
202 | | - }) |
203 | | - .unwrap_or_else(|_| "<not utf8 string>".to_owned()) |
| 194 | + let f = |out| { |
| 195 | + let out = String::from_utf8_lossy(out); |
| 196 | + if out.is_empty() { |
| 197 | + Cow::Borrowed("<empty>") |
| 198 | + } else { |
| 199 | + out |
| 200 | + } |
204 | 201 | }; |
205 | 202 |
|
206 | | - eprintln!("===== request ====="); |
207 | | - eprintln!("{}", request_uri); |
208 | | - eprintln!("===== stdout ======"); |
209 | | - eprintln!("{}", f(stdout)); |
210 | | - eprintln!("===== stderr ======"); |
211 | | - eprintln!("{}", f(stderr)); |
| 203 | + debug!(uri:% = request_uri, stdout:% = f(&stdout), stderr:% = f(&stderr); "test php request"); |
212 | 204 |
|
213 | 205 | assert!(no_error, "request not success: {}", request_uri); |
214 | 206 | } |
|
0 commit comments