Permalink
Browse files

drools works!

  • Loading branch information...
1 parent 595c1f2 commit df9313918d11cb6749c385d374a47a09475101fe @narkisr narkisr committed Apr 2, 2012
Showing with 12 additions and 6 deletions.
  1. +1 −0 resources/log4j.properties
  2. +1 −1 src/gelfino/example.clj
  3. +10 −5 src/gelfino/streams.clj
@@ -13,6 +13,7 @@ log4j.logger.gelfino.statistics=INFO,GelfinoFileAppender
log4j.logger.gelfino.core=INFO,Console
log4j.logger.gelfino.bootstrap=INFO,Console
log4j.logger.gelfino.udp=INFO,Console
+log4j.logger.gelfino.example=INFO,Console
log4j.logger.gelfino.streams=INFO,Console
log4j.logger.gelfino.chunked=INFO,Console
log4j.logger.lamina=INFO,Console
View
@@ -23,7 +23,7 @@
(defstream level :level (fn [v] (= "INFO" v)) (fnordic-even "info"))
(defrule inf-rule
- (when $message :> Message (== level "INFO" )
+ (when $message :> Message (== level 6 )
:from (entry-point "event-stream"))
(then
(info "info detected by drools")))
View
@@ -68,15 +68,20 @@
(fn [jsons#]
(receive-all jsons#
(fn [m#]
- (info m#)
- (.insert entry# (Message. (m# :level) (m# :timestamp)))
- (.fireAllRules session#)))))))
+ (if (or (nil? (.longValue (m# :timestamp))) (nil? (m# :level)))
+ (error "no timestamp or level value given for message")
+ (do
+ (info (str m#))
+ (.insert entry# (Message. (m# :level) (.longValue (m# :timestamp))))
+ (.fireAllRules session#)))))))))
+
+
(defn selectors-stream [name rest]
`(let [stream-input# (channel)]
(swap! stream-channels assoc ~(keyword name)
- (fn [jsons#]
- (receive-all (filter* (filter-fn '~rest) jsons#) ~(apply-sym 'message (last rest)))))))
+ (fn [jsons#]
+ (receive-all (filter* (filter-fn '~rest) jsons#) ~(apply-sym 'message (last rest)))))))
(defmacro defstream
"A stream of messages filtered out of the entire messages recieved

0 comments on commit df93139

Please sign in to comment.