diff --git a/binding.gyp b/binding.gyp index 5579ff6..7e93ea7 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,6 +1,9 @@ { "targets": [ { "target_name": "syslog", - "sources": [ "src/syslog.cc" ] + "sources": [ "src/syslog.cc" ], + "include_dirs": [ + "=0.8" - } + "name": "bunyan-syslog", + "description": "Syslog Stream for Bunyan", + "version": "0.2.2", + "author": "Mark Cavage", + "main": "./lib/index.js", + "repository": { + "type": "git", + "url": "git://github.com/mcavage/node-bunyan-syslog.git" + }, + "dependencies": { + "assert-plus": "0.1.4", + "nan": "^1.6.1" + }, + "devDependencies": { + "bunyan": "0.21.4", + "tap": "0.4.4" + }, + "scripts": { + "test": "tap test" + }, + "engines": { + "node": ">=0.8" + } } diff --git a/src/syslog.cc b/src/syslog.cc index 605e8ee..4da7ff5 100644 --- a/src/syslog.cc +++ b/src/syslog.cc @@ -4,17 +4,18 @@ #include #include +#include using namespace v8; #define RETURN_EXCEPTION(MSG) \ - return ThrowException(Exception::Error(String::New(MSG))) + NanThrowError(MSG) #define RETURN_ARGS_EXCEPTION(MSG) \ - return ThrowException(Exception::TypeError(String::New(MSG))) + NanThrowError(MSG) #define RETURN_ERRNO_EXCEPTION(RC, API, MSG) \ - return ThrowException(node::ErrnoException(RC, API, MSG)) + NanThrowError(node::ErrnoException(RC, API, MSG)) #define RETURN_OOM_EXCEPTION() \ RETURN_ERRNO_EXCEPTION(ENOMEM, "malloc", strerror(ENOMEM)) @@ -53,9 +54,8 @@ using namespace v8; ///--- API - -Handle Open(const Arguments& args) { - HandleScope scope; +NAN_METHOD(Open) { + NanScope(); REQUIRE_STRING_ARG(args, 0, ident); REQUIRE_INT_ARG(args, 1, logopt); @@ -63,42 +63,38 @@ Handle Open(const Arguments& args) { openlog(strdup(*ident), logopt, facility); - return (Undefined()); + NanReturnUndefined(); } - -Handle Log(const Arguments& args) { - HandleScope scope; +NAN_METHOD(Log) { + NanScope(); REQUIRE_INT_ARG(args, 0, priority); REQUIRE_STRING_ARG(args, 1, message); syslog(priority, "%s", *message); - return (Undefined()); + NanReturnUndefined(); } - -Handle Close(const Arguments& args) { - HandleScope scope; +NAN_METHOD(Close) { + NanScope(); closelog(); - return (Undefined()); + NanReturnUndefined(); } - -Handle Mask(const Arguments& args) { - HandleScope scope; +NAN_METHOD(Mask) { + NanEscapableScope(); REQUIRE_INT_ARG(args, 0, maskpri); int mask = setlogmask(LOG_UPTO(maskpri)); - return (scope.Close(Integer::New(mask))); + NanReturnValue(NanEscapeScope(NanNew(mask))); } - void init(Handle target) { NODE_SET_METHOD(target, "openlog", Open); NODE_SET_METHOD(target, "syslog", Log);