-
-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathlogger.js
More file actions
50 lines (43 loc) · 1.34 KB
/
logger.js
File metadata and controls
50 lines (43 loc) · 1.34 KB
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
import GObject from 'gi://GObject';
import Gio from 'gi://Gio';
export const CoverflowLogger = new GObject.registerClass({
GTypeName: "CoverflowLogger",
Properties: {
'verbose_logging': GObject.ParamSpec.boolean(
`verbose_logging`,
`Verbose`,
`Verbose Log messages.`,
GObject.ParamFlags.READWRITE,
false,
),
}
}, class CoverflowLogger extends GObject.Object {
constructor(settings) {
super();
this.settings = settings;
this.settings.bind('verbose-logging', this, 'verbose_logging', Gio.SettingsBindFlags.DEFAULT);
this.indent = " ";
this.depth = 0;
}
increaseIndent() {
this.depth += 1;
}
decreaseIndent() {
this.depth = Math.max(0, this.depth - 1);
}
log(msg) {
if (this.verbose_logging)
console.log(`${this.prepareMessage('[LOG ] ' + this.indent.repeat(this.depth) + msg)}`);
}
error(msg) {
console.log(`${this.prepareMessage('[ERROR] ' + this.indent.repeat(this.depth) + msg)}`)
}
debug(msg) {
if (this.verbose_logging) {
console.log(`${this.prepareMessage('[DEBUG] ' + this.indent.repeat(this.depth) + msg)}`);
}
}
prepareMessage(msg) {
return `[CoverflowAltTab@palatis.blogspot.com]${msg}`;
}
});