Http log parser in LISP.
Updated my old LISP parser of the http logs to support date and time parameters, cleaned up code a bit and improved performance a little.
What I really like in LISP is its nature. It is just perfect to be used for some obscure project when you slack after some other (potentially hard) task. And while result may be far from the perfect code, it still does its job of brain relaxation.
That’s the parts of my (rather bad I do not argue) code:
(defun filter-urls (check-list rules) (let ((l check-list) (res '())) (setf l (remove-if #'(lambda (check) (let ((str-to-push check)) (dolist (r rules) (let* ((match (first r)) (trans (second r))) (when (search match check) (when trans (when (eql 0 (count trans res :test #'string=)) (push trans res))) (setf str-to-push nil) (return t)))) (when (not (null str-to-push)) (when (eql 0 (count check res :test #'string=)) (push check res))) t)) l)) res)) (defmethod dump-short-block ((inst address-instance)) (with-slots (atime get_urls post_urls empty addr refs) inst (setf get_urls (filter-urls get_urls *filter-rules*)) (setf post_urls (filter-urls post_urls *filter-rules*)) (setf refs (filter-urls (filter-urls refs *filter-refs*) *filter-rules*)) (when (or (not (null get_urls)) (not (null post_urls))) (dump-block inst))))
Next task is to find out a way to get data from the DNS server, likely via:
> (dolist (a (hostent-addr-list (resolve-host-ipaddr "www.kernel.org"))) (format t "addr: ~A, name: ~A~%" a (hostent-name (resolve-host-ipaddr a)))) addr: 18.104.22.168, name: www.kernel.org
Its main advantage is that it is very different from the-best-ever
high-level-assembler language C.
Edited to fix the title