homebrew-core/Formula/jlog.rb

66 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.4.0.tar.gz"
sha256 "3843c48ca5c0debe22ea2d2f7de5c1a17a046699e628fd0a0a41ada14b0fece7"
head "https://github.com/omniti-labs/jlog.git"
bottle do
cellar :any
sha256 "1510fc25b9c815257ec72fdc4fd1b9e1bb62820e01227b35d24cb625ac20b1c5" => :catalina
sha256 "a150cb591f0a5a1c2feea38a6f541923b29f4d0bf75312c7b630c676c0239906" => :mojave
sha256 "731b28fcdc22a3c8241bc5c3979ce3b661b6eb958af1654a76c3e19eb0ef7b5d" => :high_sierra
sha256 "0525a5fbb6c25e606356e79dc43ea6996d99b8474d74686330be06c6d1c08749" => :sierra
end
depends_on "autoconf" => :build
depends_on "automake" => :build
def install
system "autoconf"
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"jlogtest.c").write <<~EOS
#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);
}
EOS
system ENV.cc, "jlogtest.c", "-I#{include}", "-L#{lib}", "-ljlog", "-o", "jlogtest"
system testpath/"jlogtest"
end
end