summaryrefslogtreecommitdiff
path: root/main_simple.c
diff options
context:
space:
mode:
Diffstat (limited to 'main_simple.c')
-rw-r--r--main_simple.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/main_simple.c b/main_simple.c
index 07b577d..84753c9 100644
--- a/main_simple.c
+++ b/main_simple.c
@@ -30,13 +30,17 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-
+#include <unistd.h>
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
int main(int argc, char *argv[])
{
- int fd = open("/tmp/my.log", O_CREAT | O_RDWR, 0777);
+ const char *mylog = "/tmp/my.log";
+ int fd = open(mylog, O_CREAT | O_RDWR, 0777);
if(fd == -1) {
+ printf("Could not open '%s' for writing: %s", mylog, strerror(errno));
return 1;
}
@@ -46,7 +50,7 @@ int main(int argc, char *argv[])
HUG_FLAG_OUTPUT_TO_STDERR |
0,
HUG_OPTION_FD, fd,
- HUG_OPTION_FILENAME, "/tmp/my2.log",
+ HUG_OPTION_FILENAME, "/tmp/my.log2",
HUG_OPTION_STDOUT_NO_DATE, 0,
HUG_OPTION_END);
@@ -57,11 +61,16 @@ int main(int argc, char *argv[])
INFO(example, "We are up and running");
- DEBUG(example, "Or are we %d?", 42);
+ DEBUG(example, "Or are we %d %s?", 42, "hello");
- DEBUG(foo, "Or are we %d?", 42);
+ const char bar[] = "bar";
+ (void)bar; // Ignore if compiled with hugin disabled.
+ DEBUG(foo, "Or are we %d %s?", 42, bar);
hug_close();
+ unlink(mylog);
+ unlink("/tmp/my.log2");
+
return 0;
}