summaryrefslogtreecommitdiff
path: root/folks
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2011-04-23 00:58:54 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2011-05-02 21:23:57 +0100
commit2c71358301f6da87186acf3c3405c55df3c5fe57 (patch)
tree9b666beb2409143f7088094399e3fa276fa07ed2 /folks
parentc5ef70859ff19c46f6e3a08a3816a1fc3e0cb6d2 (diff)
Allow enabling/disabling output of debug messages at runtime
Helps: bgo#648533
Diffstat (limited to 'folks')
-rw-r--r--folks/debug.vala46
1 files changed, 44 insertions, 2 deletions
diff --git a/folks/debug.vala b/folks/debug.vala
index ac5f043..e7cbfe6 100644
--- a/folks/debug.vala
+++ b/folks/debug.vala
@@ -42,15 +42,57 @@ public class Folks.Debug : Object
private HashSet<string> _domains;
private bool _all = false;
+ private bool _debug_output_enabled = true;
+
+ /**
+ * Whether debug output is enabled. This is orthogonal to the set of enabled
+ * debug domains; filtering of debug output as a whole is done after filtering
+ * by enabled domains.
+ *
+ * @since UNRELEASED
+ */
+ public bool debug_output_enabled
+ {
+ get
+ {
+ lock (this._debug_output_enabled)
+ {
+ return this._debug_output_enabled;
+ }
+ }
+
+ set
+ {
+ lock (this._debug_output_enabled)
+ {
+ this._debug_output_enabled = value;
+ }
+ }
+ }
+
+ private void _log_handler_cb (string? log_domain,
+ LogLevelFlags log_levels,
+ string message)
+ {
+ if (this.debug_output_enabled == false)
+ {
+ /* Don't output anything if debug output is disabled, even for
+ * enabled debug domains. */
+ return;
+ }
+
+ /* Otherwise, pass through to the default log handler */
+ Log.default_handler (log_domain, log_levels, message);
+ }
+
/* turn off debug output for the given domain unless it was in the FOLKS_DEBUG
* environment variable (or 'all' was set) */
internal void _register_domain (string domain)
{
if (this._all || this._domains.contains (domain.down ()))
{
- /* FIXME: shouldn't need to cast. See bgo#638682 */
Log.set_handler (domain, LogLevelFlags.LEVEL_MASK,
- (LogFunc) Log.default_handler);
+ this._log_handler_cb);
return;
}