[syslog-ng] [ANN]: balabit.logstore 0.1.0 - Open Source LogStore reader API
Gergely Nagy
algernon at balabit.hu
Wed Dec 19 15:20:17 CET 2012
Gergely Nagy <algernon at balabit.hu> writes:
> EXAMPLE:
>
> Clojure:
>
> (ns example
> (:require [balabit.logstore.sweet :as logstore]))
>
> (prn (logstore/messages (logstore/from-file "/path/to/logstore/messages.store")))
>
> Java:
A short followup on this part: as I wrote in the announcement, the Java
API is being constantly improved. So much so, that the below example can
now be rewritten much simpler:
> import BalaBit.LogStore;
> import clojure.lang.LazySeq;
> import clojure.lang.Keyword;
> import java.util.Map;
>
> public class LGSCat {
> public static void main(String[] args) {
> Keyword k = BalaBit.LogStore.keyword("MESSAGE");
> Object o = BalaBit.LogStore.fromFile (args[0]);
> LazySeq s = (LazySeq) BalaBit.LogStore.messages (o);
>
> for (Object m : s.toArray()) {
> Map msg = (Map) m;
> System.out.println(msg.get(k));
> }
> }
> }
..becomes:
import BalaBit.LogStoreMap;
import BalaBit.LogStore;
import java.util.Map;
public class LGSCat {
public static void main (String[] args) {
LogStore lgs = new LogStore (args[0]);
for (Object m : lgs.messages ()) {
LogStoreMap msg = new LogStoreMap (m);
System.out.println (msg.get("MESSAGE"));
}
}
}
No more clojure.lang.* imports, no more LazySeq, no more keyword
hackery, and everything's neatly tucked away under two simple classes.
If there are any Java hackers out there, who would be willing to give me
suggestions on how to improve the Java API further, please do let me
know! (I barely speak Java, so what I find convenient, may very well not
be found as such by others.)
I'll iron out a few things, and add ability to do verification (as in,
throwing proper exceptions when a LogStore file is found to be broken,
instead of hoping that something somewhere will break and throw one for
us), then release another version, this time with JARs uploaded aswell.
--
|8]
More information about the syslog-ng
mailing list