summaryrefslogtreecommitdiffstats
path: root/src/afb-hreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-10 16:23:40 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-10 16:23:40 +0200
commit7ea1657b459aea2cc6ef9332621a19d7e2676b1d (patch)
tree06f1db05c70debfcd3be3447e6284eabd00d98b7 /src/afb-hreq.c
parentf1b901ed676b2d45ec8e6ae3d6ef2f94d79f9ee6 (diff)
refactored logging
Change-Id: Iec97d679b7e3baa430e614f8e6336d6487de0f25 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hreq.c')
-rw-r--r--src/afb-hreq.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/afb-hreq.c b/src/afb-hreq.c
index 518bc5cb..5eb0cc56 100644
--- a/src/afb-hreq.c
+++ b/src/afb-hreq.c
@@ -234,18 +234,15 @@ static magic_t lazy_libmagic()
done = 1;
/* MAGIC_MIME tells magic to return a mime of the file,
but you can specify different things */
- if (verbosity)
- fprintf(stderr, "Loading mimetype default magic database\n");
-
+ INFO("Loading mimetype default magic database");
result = magic_open(MAGIC_MIME_TYPE);
if (result == NULL) {
- fprintf(stderr,"ERROR: unable to initialize magic library\n");
+ ERROR("unable to initialize magic library");
}
/* Warning: should not use NULL for DB
[libmagic bug wont pass efence check] */
else if (magic_load(result, MAGIC_DB) != 0) {
- fprintf(stderr,"cannot load magic database - %s\n",
- magic_error(result));
+ ERROR("cannot load magic database: %s", magic_error(result));
magic_close(result);
result = NULL;
}
@@ -435,8 +432,7 @@ int afb_hreq_reply_file_if_exist(struct afb_hreq *hreq, int dirfd, const char *f
if (inm && 0 == strcmp(inm, etag)) {
/* etag ok, return NOT MODIFIED */
close(fd);
- if (verbosity)
- fprintf(stderr, "Not Modified: [%s]\n", filename);
+ DEBUG("Not Modified: [%s]", filename);
response = MHD_create_response_from_buffer(0, empty_string, MHD_RESPMEM_PERSISTENT);
status = MHD_HTTP_NOT_MODIFIED;
} else {
@@ -477,8 +473,7 @@ int afb_hreq_redirect_to(struct afb_hreq *hreq, const char *url)
{
afb_hreq_reply_static(hreq, MHD_HTTP_MOVED_PERMANENTLY, 0, NULL,
MHD_HTTP_HEADER_LOCATION, url, NULL);
- if (verbosity)
- fprintf(stderr, "redirect from [%s] to [%s]\n", hreq->url, url);
+ DEBUG("redirect from [%s] to [%s]", hreq->url, url);
return 1;
}