Commit 85339221 authored by Leigh Stoller's avatar Leigh Stoller

Add logging calls as defined in lib/libtb. Add debug option as well

for verbosity.
parent 3de70d86
......@@ -13,6 +13,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "log.h"
#include "event.h"
......@@ -61,6 +62,7 @@ main(int argc, char **argv)
if (argc != 1)
usage();
loginit("tbmevc", 0);
/*
* Uppercase event tags for now. Should be wired in list instead.
......@@ -80,13 +82,11 @@ main(int argc, char **argv)
struct in_addr myip;
if (gethostname(buf, sizeof(buf)) < 0) {
ERROR("could not get hostname\n");
return 1;
fatal("could not get hostname");
}
if (! (he = gethostbyname(buf))) {
ERROR("could not get IP address from hostname\n");
return 1;
fatal("could not get IP address from hostname");
}
memcpy((char *)&myip, he->h_addr, he->h_length);
strcpy(ipbuf, inet_ntoa(myip));
......@@ -111,39 +111,34 @@ main(int argc, char **argv)
*/
tuple = address_tuple_alloc();
if (tuple == NULL) {
ERROR("could not allocate an address tuple\n");
return 1;
fatal("could not allocate an address tuple");
}
tuple->objtype = OBJECTTYPE_TESTBED;
tuple->objname = argv[0];
tuple->eventtype= argv[0];
tuple->host = ipaddr;
/* Register with the event system: */
handle = event_register(server, 0);
if (handle == NULL) {
ERROR("could not register with event system\n");
return 1;
fatal("could not register with event system");
}
/* Generate the event */
notification = event_notification_alloc(handle, tuple);
if (notification == NULL) {
ERROR("could not allocate notification\n");
return 1;
fatal("could not allocate notification");
}
if (event_notify(handle, notification) == 0) {
ERROR("could not send test event notification\n");
return 1;
fatal("could not send test event notification");
}
event_notification_free(handle, notification);
/* Unregister with the event system: */
if (event_unregister(handle) == 0) {
ERROR("could not unregister with event system\n");
return 1;
fatal("could not unregister with event system");
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment