Geary.Logging: Enable API clients to suppress DEBUG logging per-domain
This commit is contained in:
parent
972744c5dc
commit
718f02bd8a
2 changed files with 41 additions and 8 deletions
|
|
@ -359,6 +359,7 @@ private unowned FileStream? stream = null;
|
|||
public void init() {
|
||||
if (init_count++ != 0)
|
||||
return;
|
||||
Logging.suppressed_domains = new Gee.HashSet<string>();
|
||||
record_lock = GLib.Mutex();
|
||||
writer_lock = GLib.Mutex();
|
||||
max_log_length = DEFAULT_MAX_LOG_BUFFER_LENGTH;
|
||||
|
|
@ -571,12 +572,13 @@ public GLib.LogWriterOutput default_log_writer(GLib.LogLevelFlags levels,
|
|||
}
|
||||
|
||||
private bool should_blacklist(Record record) {
|
||||
const string DOMAIN_PREFIX = Logging.DOMAIN + ".";
|
||||
return (
|
||||
// GdkPixbuf spams us e.g. when window focus changes,
|
||||
// including between MainWindow and the Inspector, which is
|
||||
// very annoying.
|
||||
(record.levels == GLib.LogLevelFlags.LEVEL_DEBUG &&
|
||||
record.domain == "GdkPixbuf") ||
|
||||
// Don't need to check for the engine's domains, they were
|
||||
// already handled by Source's methods.
|
||||
(record.domain != Logging.DOMAIN &&
|
||||
!record.domain.has_prefix(DOMAIN_PREFIX) &&
|
||||
record.domain in Logging.suppressed_domains) ||
|
||||
// GAction does not support disabling parameterised actions
|
||||
// with specific values, but GTK complains if the parameter is
|
||||
// set to null to achieve the same effect, and they aren't
|
||||
|
|
|
|||
|
|
@ -7,6 +7,35 @@
|
|||
*/
|
||||
|
||||
|
||||
namespace Geary.Logging {
|
||||
|
||||
|
||||
internal Gee.Set<string> suppressed_domains;
|
||||
|
||||
|
||||
/**
|
||||
* Suppresses debug logging for a given logging domain.
|
||||
*
|
||||
* If a logging domain is suppressed, DEBUG-level logging will not
|
||||
* be sent to the logging system.
|
||||
*
|
||||
* @see unsuppress_domain
|
||||
*/
|
||||
public void suppress_domain(string domain) {
|
||||
Logging.suppressed_domains.add(domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-suppresses debug logging for a given logging domain.
|
||||
*
|
||||
* @see suppress_domain
|
||||
*/
|
||||
public void unsuppress_domain(string domain) {
|
||||
Logging.suppressed_domains.remove(domain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin interface for objects that support structured logging.
|
||||
*
|
||||
|
|
@ -167,9 +196,11 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
*/
|
||||
[PrintfFormat]
|
||||
public inline void debug(string fmt, ...) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
|
||||
);
|
||||
if (!(this.logging_domain in Logging.suppressed_domains)) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue