diff options
-rw-r--r-- | discover/discover-server.c | 4 | ||||
-rw-r--r-- | discover/params.c | 8 | ||||
-rw-r--r-- | discover/pb-discover.c | 12 | ||||
-rw-r--r-- | discover/udev.c | 4 |
4 files changed, 20 insertions, 8 deletions
diff --git a/discover/discover-server.c b/discover/discover-server.c index e03a44a..47ab494 100644 --- a/discover/discover-server.c +++ b/discover/discover-server.c @@ -66,12 +66,12 @@ static void print_clients(struct discover_server *server) { struct client *client; - printf("current clients [%p,%p,%p]:\n", + pb_log("current clients [%p,%p,%p]:\n", &server->clients.head, server->clients.head.prev, server->clients.head.next); list_for_each_entry(&server->clients, client, list) - printf("\t[%p,%p,%p] client: %d\n", &client->list, + pb_log("\t[%p,%p,%p] client: %d\n", &client->list, client->list.prev, client->list.next, client->fd); } diff --git a/discover/params.c b/discover/params.c index 76a1451..d78730a 100644 --- a/discover/params.c +++ b/discover/params.c @@ -28,10 +28,10 @@ #define realloc_array(ptr, type, num) \ ((type *)_realloc_array((ptr), sizeof(type), (num))) -#define rprintf(x, ...) do { fprintf(stderr, ##__VA_ARGS__); \ - fprintf(stderr, "\n"); } while (0) -#define rsyserr(x, y, ...) do { fprintf(stderr, ##__VA_ARGS__); \ - fprintf(stderr, "\n"); } while (0) +#define rprintf(x, ...) do { pb_log(stderr, ##__VA_ARGS__); \ + pb_log(stderr, "\n"); } while (0) +#define rsyserr(x, y, ...) do { pb_log(stderr, ##__VA_ARGS__); \ + pb_log(stderr, "\n"); } while (0) #define MALLOC_MAX 0x40000000 #define False 0 diff --git a/discover/pb-discover.c b/discover/pb-discover.c index d8709b3..2b04e62 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -1,4 +1,5 @@ +#include <assert.h> #include <stdlib.h> #include <signal.h> @@ -21,6 +22,16 @@ int main(void) struct device_handler *handler; struct discover_server *server; struct udev *udev; + FILE *log; + + log = fopen("pb-discover.log", "a"); + assert(log); + pb_log_set_stream(log); + +#if defined(DEBUG) + pb_log_always_flush(1); +#endif + pb_log("--- pb-discover ---\n"); /* we look for closed sockets when we write, so ignore SIGPIPE */ signal(SIGPIPE, SIG_IGN); @@ -48,6 +59,7 @@ int main(void) device_handler_destroy(handler); + pb_log("--- end ---\n"); return EXIT_SUCCESS; } diff --git a/discover/udev.c b/discover/udev.c index 9d62840..b93c1a5 100644 --- a/discover/udev.c +++ b/discover/udev.c @@ -82,10 +82,10 @@ static void print_event(struct udev_event *event) action = event->action == UDEV_ACTION_ADD ? "add" : "remove"; pb_log("udev %s event:\n", action); - printf("\tdevice: %s\n", event->device); + pb_log("\tdevice: %s\n", event->device); for (i = 0; params[i]; i++) - printf("\t%-12s => %s\n", + pb_log("\t%-12s => %s\n", params[i], udev_event_param(event, params[i])); } |