summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2013-07-05 12:09:16 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2013-07-06 11:39:55 +0100
commit91d2b71d863eb506716d015b48c9fb0e21ef20f4 (patch)
tree235b4a566394bde4bfc99f13ebf3a2bd73eaabea
parentb6a9fae3c9249e59d6937ebef2768b2cd2049020 (diff)
Add -verbose option
Add -verbose option to increase debug verbosity Document -verbose option in man page Turn on more libxcwm logging when verbosity is requested Put XWinWMUtil debug output at verbosity level 2
-rw-r--r--man/xtow.man3
-rw-r--r--src/debug.c31
-rw-r--r--src/debug.h6
-rw-r--r--src/main.c12
4 files changed, 44 insertions, 8 deletions
diff --git a/man/xtow.man b/man/xtow.man
index b41963b..8d2b744 100644
--- a/man/xtow.man
+++ b/man/xtow.man
@@ -27,6 +27,9 @@ supported.
If DWM is available, use the glass effect to blur the image beneath transparent areas.
.B \-noshm
Do not use MIT-SHM to transfer window images from the X server, even if available.
+.TP 8
+.B \-verbose
+Output verbose debugging information. Multiple -verbose options increase verbosity.
.SH "WINDOW PROPERTIES"
Partial conformance to ICCCM and EWMH standards.
diff --git a/src/debug.c b/src/debug.c
index 5495cd8..e143d46 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -22,19 +22,42 @@
#include "debug.h"
-#if 1
+int verbosity = 0;
+
+static
+int winVDebugVerbosity(int level, const char *format, va_list ap)
+{
+ int count = 0;
+ if (level <= verbosity)
+ {
+ count = fprintf(stderr, "xtow: ");
+ count += vfprintf(stderr, format, ap);
+ }
+ return count;
+}
+
+int winDebugVerbosity(int level, const char *format, ...)
+{
+ int count;
+ va_list ap;
+ va_start(ap, format);
+ count = winVDebugVerbosity(level, format, ap);
+ va_end(ap);
+ return count;
+}
+
+#define DEBUG_VERBOSITY_DEFAULT 2
+
int
winDebug(const char *format, ...)
{
int count;
va_list ap;
va_start(ap, format);
- count = fprintf(stderr, "xtow: ");
- count += vfprintf(stderr, format, ap);
+ count = winVDebugVerbosity(DEBUG_VERBOSITY_DEFAULT, format, ap);
va_end(ap);
return count;
}
-#endif
int
winError(const char *format, ...)
diff --git a/src/debug.h b/src/debug.h
index dd4daf2..32c0a1d 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -23,10 +23,12 @@
int winError(const char *format, ...);
#if 1
+int verbosity;
int winDebug(const char *format, ...);
-#define DEBUG winDebug
+int winDebugVerbosity(int level, const char *format, ...);
+#define DEBUG(Args...) winDebugVerbosity(1, Args)
#else
-#define DEBUG(Args...)
+#define DEBUG(Arg...)
#endif
#endif /* DEBUG_H */
diff --git a/src/main.c b/src/main.c
index 5eee9a2..b50eaa4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -126,6 +126,7 @@ help(void)
fprintf(stderr, "--help\n");
fprintf(stderr, "--nodwm do not use DWM, even if available\n");
fprintf(stderr, "--noshm do not use SHM, even if available\n");
+ fprintf(stderr, "--verbose output verbose debug logging\n");
exit(0);
}
@@ -146,12 +147,13 @@ int main(int argc, char **argv)
{
static struct option long_options[] =
{
- { "version", no_argument, 0, 'v' },
+ { "version", no_argument, 0, 'V' },
{ "display", required_argument, 0, 'd' },
{ "help", no_argument, 0, 'h' },
{ "blur", no_argument, 0, 'b' },
{ "nodwm", no_argument, 0, 'n' },
{ "noshm", no_argument, 0, 's' },
+ { "verbose", no_argument, 0, 'v' },
{0, 0, 0, 0 },
};
@@ -175,9 +177,12 @@ int main(int argc, char **argv)
case 's':
noshm = 1;
break;
- case 'v':
+ case 'V':
version();
break;
+ case 'v':
+ verbosity++;
+ break;
case 'h':
default:
help();
@@ -216,6 +221,9 @@ int main(int argc, char **argv)
flags = XCWM_DISABLE_SHM;
}
+ if (verbosity > 1)
+ flags = XCWM_VERBOSE_LOG_XEVENTS;
+
// create the global xcwm context
context = xcwm_context_open(screen, flags);
if (!context)