blob: 070a9413d948d7816ee6ccd37686061eb74f38ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
Copyright (C) 2018 Christian Dywan <christian@twotoats.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
See the file COPYING for the full license text.
*/
namespace Midori {
public const DebugKey[] keys = {
{ "historydatabase", DebugFlags.HISTORY },
};
public enum DebugFlags {
NONE,
HISTORY,
}
public interface Loggable : Object {
public string domain { owned get {
string? _domain = get_data<string> ("midori-domain");
if (_domain == null) {
_domain = get_type ().name ().substring (6, -1).down ();
set_data<string> ("midori-domain", _domain);
}
return _domain;
} }
public bool logging { owned get {
bool? _logging = get_data<bool?> ("midori-logging");
if (_logging == null) {
uint flag = int.MAX;
foreach (var key in keys) {
if (key.key == domain) {
flag = key.value;
}
}
string debug_string = Environment.get_variable ("G_MESSAGES_DEBUG");
uint flags = parse_debug_string (debug_string, keys);
_logging = (flags & flag) != 0;
set_data<bool?> ("midori-logging", _logging);
}
return _logging;
} }
public void debug (string format, ...) {
logv (domain, LogLevelFlags.LEVEL_DEBUG, format, va_list ());
}
}
}
|