Skip to content

Instantly share code, notes, and snippets.

@siscia
Forked from MichaelDrogalis/gist:5326714
Last active December 15, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siscia/5338109 to your computer and use it in GitHub Desktop.
Save siscia/5338109 to your computer and use it in GitHub Desktop.
(ns project.logging
(:require [clojure.tools.logging :refer [info warn]]
[dire.core :refer [with-pre-hook!]]
[project.destructure :refer :all]))
(with-pre-hook! #'destructure-cow-list
(fn [connection]
(info connection "is listing cows.")))
(with-pre-hook! #'destructure-cow-create
(fn [connection message]
(info connection "is creating a cow:" message)))
(with-pre-hook! #'destructure-chicken-bind
(fn [connection message]
(info connection "is binding to a chicken:" message)))
(with-pre-hook! #'destructure-chicken-unbind
(fn [connection]
(info connection "is unbinding from a chicken.")))
;; It would probably need to be a macro, just to give you an idea of what I was talking about.
(def(macro ?) pre-hook-animal [function, message]
(with-pre-hook! function
(fn [connection]
(info connection message))))
;; and then:
(pre-hook-animal #'destructure-cow-list "is listing cows.")
(pre-hook-animal #'destructure-chicken-unbid "is unbinding from a chicken.")
;; and some trick to put inside also the one who use the message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment