homebrew-core/Formula/jlog.rb
2017-09-21 10:03:05 +02:00

65 lines
2.3 KiB
Ruby

class Jlog < Formula
desc "Pure C message queue with subscribers and publishers for logs"
homepage "https://labs.omniti.com/labs/jlog"
url "https://github.com/omniti-labs/jlog/archive/2.3.0.tar.gz"
sha256 "b8912e8de791701d664965c30357c4bbc68df3206b22f7ea0029e7179b02079a"
head "https://github.com/omniti-labs/jlog.git"
bottle do
cellar :any
sha256 "68d1057ab73d4b1548bbcbfe27e16789d4a2ed66abbe87b49950824287c1c356" => :high_sierra
sha256 "32a6766cb3c60af8e6b47bd80b81362a95e0c27ce57e078f42385af443af49f1" => :sierra
sha256 "b7a9ed90a1f393772747a0c64b60fe07569f963f03f294455cbf569969b3319e" => :el_capitan
sha256 "1479a30b96d3b41eee289a2ffb01ed4d0bb1b45c325bb80c8cc8430f9e7f4052" => :yosemite
end
depends_on "automake" => :build
depends_on "autoconf" => :build
def install
system "autoconf"
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"jlogtest.c").write <<-EOF.undent
#include <stdio.h>
#include <jlog.h>
int main() {
jlog_ctx *ctx;
const char *path = "#{testpath}/jlogexample";
int rv;
// First, ensure that the jlog is created
ctx = jlog_new(path);
if (jlog_ctx_init(ctx) != 0) {
if(jlog_ctx_err(ctx) != JLOG_ERR_CREATE_EXISTS) {
fprintf(stderr, "jlog_ctx_init failed: %d %s\\n", jlog_ctx_err(ctx), jlog_ctx_err_string(ctx));
exit(1);
}
// Make sure it knows about our subscriber(s)
jlog_ctx_add_subscriber(ctx, "one", JLOG_BEGIN);
jlog_ctx_add_subscriber(ctx, "two", JLOG_BEGIN);
}
// Now re-open for writing
jlog_ctx_close(ctx);
ctx = jlog_new(path);
if (jlog_ctx_open_writer(ctx) != 0) {
fprintf(stderr, "jlog_ctx_open_writer failed: %d %s\\n", jlog_ctx_err(ctx), jlog_ctx_err_string(ctx));
exit(0);
}
// Send in some data
rv = jlog_ctx_write(ctx, "hello\\n", strlen("hello\\n"));
if (rv != 0) {
fprintf(stderr, "jlog_ctx_write_message failed: %d %s\\n", jlog_ctx_err(ctx), jlog_ctx_err_string(ctx));
}
jlog_ctx_close(ctx);
}
EOF
system ENV.cc, "jlogtest.c", "-I#{include}", "-L#{lib}", "-ljlog", "-o", "jlogtest"
system testpath/"jlogtest"
end
end