Skip to content

Instantly share code, notes, and snippets.

@njh
Created June 3, 2011 15:39
Show Gist options
  • Select an option

  • Save njh/1006553 to your computer and use it in GitHub Desktop.

Select an option

Save njh/1006553 to your computer and use it in GitHub Desktop.
diff --git a/utils/roqet.c b/utils/roqet.c
index 910beea..5c95727 100644
--- a/utils/roqet.c
+++ b/utils/roqet.c
@@ -124,6 +124,7 @@ static struct option long_options[] =
static int error_count = 0;
+static int error_log_level = RAPTOR_LOG_LEVEL_WARN;
static const char *title_format_string = "Rasqal RDF query utility %s\n";
@@ -139,19 +140,20 @@ static const char *title_format_string = "Rasqal RDF query utility %s\n";
static void
roqet_log_handler(void* user_data, raptor_log_message *message)
{
- /* Only interested in errors and more severe */
- if(message->level < RAPTOR_LOG_LEVEL_ERROR)
- return;
-
- fprintf(stderr, "%s: Error - ", program);
- if(message->locator) {
- raptor_locator_print(message->locator, stderr);
- fwrite((void*)" - ", sizeof(char), 3, stderr);
+ if(message->level >= error_log_level) {
+ const char* level_label = raptor_log_level_get_label(message->level);
+ fprintf(stderr, "%s: %s - ", program, level_label);
+ if(message->locator) {
+ raptor_locator_print(message->locator, stderr);
+ fwrite((void*)" - ", sizeof(char), 3, stderr);
+ }
+ fputs(message->text, stderr);
+ fputc('\n',stderr);
}
- fputs(message->text, stderr);
- fputc('\n',stderr);
- error_count++;
+ /* Only count errors and more severe */
+ if(message->level >= RAPTOR_LOG_LEVEL_ERROR)
+ error_count++;
}
#define SPACES_LENGTH 80
@@ -966,6 +968,7 @@ main(int argc, char *argv[])
case 'q':
quiet = 1;
+ error_log_level = RAPTOR_LOG_LEVEL_ERROR;
break;
case 's':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment