Created
December 13, 2013 15:38
-
-
Save juven/7946091 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clj-demo.analyze-log | |
(:require [clojure.java.io :as io] | |
[clj-time.format :as fmt])) | |
; sample lines in httpd.log | |
; 50.16.207.27 - - [03/Jul/2011:22:03:46 -0500] "GET /........." | |
; somple out | |
; #<DateTime 2011-07-04T03:03:46.000Z> | |
(def httpd-format (fmt/formatter "[dd/MMM/yyyy:HH:mm:ss Z]")) | |
(defn parse-time [line] | |
(fmt/parse httpd-format | |
(re-find #"\[.+\]" line))) | |
(with-open [reader (io/reader (io/resource "httpd.log"))] | |
(doseq [line (line-seq reader)] | |
(println (parse-time line)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment