Skip to content

Commit

Permalink
Add uninform logging to crawler-add (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevali committed Sep 21, 2015
1 parent 2516451 commit 258c350
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crawler/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ main(int argc, char **argv)
t = strchr(uribuf, '\n');
if(!t)
{
log_printf(LOG_ERR, "stdin:%d: line too long, skipping\n", line + 1);
log_printf(LOG_ERR, MSG_E_CRAWL_LINETOOLONG " at stdin:%d\n", line + 1);
skip = 1;
err = 1;
continue;
Expand All @@ -120,8 +120,8 @@ main(int argc, char **argv)
*t = 0;
uri = uri_create_str(uribuf, NULL);
if(!uri)
{
log_printf(LOG_ERR, "stdin:%d: failed to parse URI <%s>\n", line, uribuf);
{
log_printf(LOG_ERR, MSG_E_CRAWL_URIPARSE "<%s> at stdin:%d\n", uribuf, line);
err = 1;
continue;
}
Expand All @@ -135,7 +135,7 @@ main(int argc, char **argv)
}
if(r)
{
log_printf(LOG_CRIT, "stdin:%d: failed to add <%s> to the crawler queue\n", line, uribuf);
log_printf(LOG_ERR, MSG_E_CRAWL_ADDFAILED " <%s> at stdin:%d\n", uribuf, line);
err = 1;
}
else
Expand All @@ -146,14 +146,14 @@ main(int argc, char **argv)
uri_destroy(uri);
}
free(uribuf);
log_printf(LOG_NOTICE, "added %d URIs to the crawler queue\n", added);
log_printf(LOG_NOTICE, MSG_N_CRAWL_UPDATED ": added %d URIs\n", added);
}
else
{
uri = uri_create_str(uristr, NULL);
if(!uri)
{
log_printf(LOG_CRIT, "failed to parse URI <%s>\n", uristr);
log_printf(LOG_CRIT, MSG_C_CRAWL_URIPARSE " <%s>\n", uristr);
return 1;
}
if(force)
Expand All @@ -166,12 +166,13 @@ main(int argc, char **argv)
}
if(r)
{
log_printf(LOG_CRIT, "failed to add <%s> to the crawler queue\n", uristr);
log_printf(LOG_CRIT, MSG_C_CRAWL_ADDFAILED " <%s>\n", uristr);
err = 1;
}
else
{
log_printf(LOG_NOTICE, "added <%s> to the crawler queue\n", uristr);

log_printf(LOG_NOTICE, MSG_N_CRAWL_UPDATED ": added <%s>\n", uristr);
}
uri_destroy(uri);
}
Expand Down
7 changes: 7 additions & 0 deletions crawler/libcrawld.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ struct processor_api_struct

/* Log messages */

/* crawld and utilities */
# define MSG_E_CRAWL_LINETOOLONG "%ANANSI-E-2000: line too long, skipping"
# define MSG_E_CRAWL_URIPARSE "%ANANSI-E-2001: failed to parse URI"
# define MSG_C_CRAWL_URIPARSE "%ANANSI-C-2001: failed to parse URI"
# define MSG_E_CRAWL_ADDFAILED "%ANANSI-E-2002: failed to add URI to crawl queue"
# define MSG_C_CRAWL_ADDFAILED "%ANANSI-E-2002: failed to add URI to crawl queue"
# define MSG_N_CRAWL_UPDATED "%ANANSI-N-2003: crawler queue updated"

/* RDBMS queue */
# define MSG_C_DB_CONNECT "%ANANSI-C-5000: failed to connect to database"
Expand Down

0 comments on commit 258c350

Please sign in to comment.