|
1 | 1 | use crate::action::Action;
|
2 | 2 | use crate::http::{Addr, Header, Request, TrustedProxies};
|
3 | 3 | use serde::{Deserialize, Serialize};
|
4 |
| -use std::time::{SystemTime, UNIX_EPOCH}; |
5 | 4 |
|
6 | 5 | #[derive(Serialize, Deserialize, Debug, Clone)]
|
7 | 6 | pub struct Log {
|
@@ -45,10 +44,7 @@ pub struct LegacyLog {
|
45 | 44 |
|
46 | 45 | impl Log {
|
47 | 46 | pub fn from_legacy(legacy: LegacyLog, proxy: String) -> Self {
|
48 |
| - let now = match SystemTime::now().duration_since(UNIX_EPOCH) { |
49 |
| - Err(_) => 0, |
50 |
| - Ok(time) => time.as_millis(), |
51 |
| - }; |
| 47 | + let now = chrono::Utc::now().timestamp() as u128; |
52 | 48 |
|
53 | 49 | Log {
|
54 | 50 | code: legacy.status_code,
|
@@ -86,10 +82,8 @@ impl Log {
|
86 | 82 | let mut referer = None;
|
87 | 83 | let mut content_type = None;
|
88 | 84 | let mut ips = Vec::new();
|
89 |
| - let duration = match SystemTime::now().duration_since(UNIX_EPOCH) { |
90 |
| - Err(_) => None, |
91 |
| - Ok(time) => time.as_millis().checked_sub(request_start_time), |
92 |
| - }; |
| 85 | + let now = chrono::Utc::now().timestamp() as u128; |
| 86 | + let duration = now.checked_sub(request_start_time); |
93 | 87 |
|
94 | 88 | match client_ip.parse::<Addr>() {
|
95 | 89 | Ok(addr) => ips.push(addr.addr),
|
|
0 commit comments