summaryrefslogtreecommitdiff
path: root/rust/src/apachelog.rs
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-12-17 15:50:27 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-12-17 16:00:19 +0100
commit8ceac0236c555979a9172c69c1a9e895d7487d6f (patch)
tree390740422d514ac62bc572d61c64e7375f2d7a27 /rust/src/apachelog.rs
parentf355162fde31a4c79b7e665b43cef2de3ba05cb5 (diff)
downloadauth-xmppmessage-8ceac0236c555979a9172c69c1a9e895d7487d6f.tar.gz
auth-xmppmessage-8ceac0236c555979a9172c69c1a9e895d7487d6f.zip
replace all with subdirectory rust/
Diffstat (limited to 'rust/src/apachelog.rs')
-rw-r--r--rust/src/apachelog.rs45
1 files changed, 0 insertions, 45 deletions
diff --git a/rust/src/apachelog.rs b/rust/src/apachelog.rs
deleted file mode 100644
index fb5d1a6..0000000
--- a/rust/src/apachelog.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-///! Prints logging similar to apache http access.log
-use std::net::IpAddr;
-use std::io::Read;
-
-use time;
-use tiny_http::{Request, Response};
-
-pub struct LogEntry {
- remote_ip_address: IpAddr,
- remote_user: String,
- request_path: String,
- time: time::Tm,
- status: u16,
- response_size: u32,
-}
-
-impl LogEntry {
- pub fn start(req: &Request) -> LogEntry {
- let entry = LogEntry {
- remote_ip_address: req.remote_addr().ip(),
- remote_user: String::new(),
- request_path: String::from(req.url()),
- time: time::now(),
- status: 0,
- response_size: 0,
- };
- return entry
- }
-
- pub fn done<R>(&mut self, _: &Response<R>, status_code: u16) where R: Read {
- self.status = status_code; // request.statuscode is not accessible :(
- self.print();
- }
-
- #[inline(always)]
- fn print(&self) {
- info!("{} - {} - [{}] \"{}\" {} {}",
- self.remote_ip_address,
- self.remote_user,
- time::strftime("%d/%b/%Y %T %z", &self.time).unwrap(),
- self.request_path,
- self.status,
- self.response_size);
- }
-}