aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorGuo Xiao2015-04-20 02:44:09 +0800
committerMike McQuaid2015-04-20 09:55:48 +0100
commit35fc6255fdbb4b69adc09c1cb75b351b89c7220b (patch)
tree156be6c6bd44516650d173bd35eaaab803bccfe7 /Library
parent8da53f2daaf75e02baab3d20baebc8aa60af904f (diff)
downloadhomebrew-35fc6255fdbb4b69adc09c1cb75b351b89c7220b.tar.bz2
jlog 2.0.1 (new formula)
Closes #38830. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/jlog.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/Library/Formula/jlog.rb b/Library/Formula/jlog.rb
new file mode 100644
index 000000000..8bb6eb5a3
--- /dev/null
+++ b/Library/Formula/jlog.rb
@@ -0,0 +1,56 @@
+class Jlog < Formula
+ homepage "https://labs.omniti.com/labs/jlog"
+ url "https://github.com/omniti-labs/jlog/archive/2.0.1.tar.gz"
+ sha256 "ce4ec8495798e4f50af878f9fc3b922a46dd41df498a5602c802757df16499b7"
+
+ depends_on "automake" => :build
+ depends_on "autoconf" => :build
+
+ def install
+ system "autoconf"
+ system "./configure", "--prefix=#{prefix}"
+ system "make"
+ 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}", "-ljlog", "-o", "jlogtest"
+ system testpath/"jlogtest"
+ end
+end