summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2016-04-07 16:25:15 +0100
committerSam Thursfield <sam@afuera.me.uk>2016-06-09 15:30:14 +0100
commitb77763df43105cac1dc8f06cb20476821ea04d23 (patch)
treec855c7a6dfaa7e1b45dd3c45f420894640a65864
parent7e8cc3dc8911853c838f76b4c4c0ec9ea51939f0 (diff)
downloadtracker-wip/sam/extract-command.tar.gz
cli: Add --verbosity option to `tracker extract`wip/sam/extract-command
This is based on the --set-log-verbosity option from `tracker daemon`. The TRACKER_VERBOSITY environment variable also works here, and overrides the value on the commandline, so I'm not sure if this patch is really necessary...
-rw-r--r--docs/manpages/tracker-extract.148
-rw-r--r--src/tracker/tracker-extract.c34
2 files changed, 79 insertions, 3 deletions
diff --git a/docs/manpages/tracker-extract.1 b/docs/manpages/tracker-extract.1
index 652912c7e..0a7076d4c 100644
--- a/docs/manpages/tracker-extract.1
+++ b/docs/manpages/tracker-extract.1
@@ -20,6 +20,54 @@ uses to extract metadata.
For more information see the libtracker-extract reference documentation.
+.SH OPTIONS
+.TP
+.B \-\-verbosity\fR=<\fILEVEL\fR>
+This sets the log verbosity for the extractor process.
+
+The possible \fILEVEL\fR options are:
+.sp
+.RS 12
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+\fIdebug\fR
+\- Show EVERYTHING, from debug messages to errors.
+.sp
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.IP \(bu 2.3
+.\}
+\fIdetailed\fR
+\- Show enough detail to understand what is happening.
+.sp
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+\fIminimal\fR
+\- Show an overview of what is going on
+.sp
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+\fIerrors\fR
+\- Show only warnings, criticals, errors or fatal events.
+.RE
+
.SH EXAMPLES
.TP
Using command line to extract metadata from a file:
diff --git a/src/tracker/tracker-extract.c b/src/tracker/tracker-extract.c
index a6f23c444..d4979f3fc 100644
--- a/src/tracker/tracker-extract.c
+++ b/src/tracker/tracker-extract.c
@@ -25,14 +25,21 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <libtracker-common/tracker-common.h>
+
+#include "tracker-config.h"
#include "tracker-extract.h"
+static gchar *verbosity;
static gchar **filenames;
#define EXTRACT_OPTIONS_ENABLED() \
((filenames && g_strv_length (filenames) > 0))
static GOptionEntry entries[] = {
+ { "verbosity", 'v', 0, G_OPTION_ARG_STRING, &verbosity,
+ N_("Sets the logging verbosity to LEVEL ('debug', 'detailed', 'minimal', 'errors') for all processes"),
+ N_("LEVEL") },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
N_("FILE"),
N_("FILE") },
@@ -41,16 +48,19 @@ static GOptionEntry entries[] = {
static gint
-extract_files (void)
+extract_files (TrackerVerbosity verbosity)
{
char **p;
char *tracker_extract_path;
+ char verbosity_str[2];
GError *error = NULL;
+ snprintf (verbosity_str, 2, "%i", verbosity);
+
tracker_extract_path = g_build_filename(LIBEXECDIR, "tracker-extract", NULL);
for (p = filenames; *p; p++) {
- char *argv[] = {tracker_extract_path, "--file", *p, NULL};
+ char *argv[] = {tracker_extract_path, "--verbosity", verbosity_str, "--file", *p, NULL};
g_spawn_sync(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL, NULL, &error);
@@ -71,7 +81,25 @@ extract_files (void)
static int
extract_run (void)
{
- return extract_files ();
+ TrackerVerbosity verbosity_level = TRACKER_VERBOSITY_ERRORS;
+
+ if (verbosity) {
+ if (g_ascii_strcasecmp (verbosity, "debug") == 0) {
+ verbosity_level = TRACKER_VERBOSITY_DEBUG;
+ } else if (g_ascii_strcasecmp (verbosity, "detailed") == 0) {
+ verbosity_level = TRACKER_VERBOSITY_DETAILED;
+ } else if (g_ascii_strcasecmp (verbosity, "minimal") == 0) {
+ verbosity_level = TRACKER_VERBOSITY_MINIMAL;
+ } else if (g_ascii_strcasecmp (verbosity, "errors") == 0) {
+ verbosity_level = TRACKER_VERBOSITY_ERRORS;
+ } else {
+ g_printerr ("%s\n",
+ _("Invalid log verbosity, try 'debug', 'detailed', 'minimal' or 'errors'"));
+ return EXIT_FAILURE;
+ }
+ }
+
+ return extract_files (verbosity_level);
}
static int