-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
45 lines (38 loc) · 1.02 KB
/
common.js
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
/*
*
* org.gnome.shell.extensions.zappoii.whatwatch common...
*
* Visit https://github.com/Zappo-II/WhatWatch for
* LICENSE and documentation
*
*/
'use strict';
import GLib from 'gi://GLib';
export var debugLogging = false;
let metadata = {
name: 'MyNameIsUndefined',
version: 'MyVersionIsUndefined'
};
export function setDebugLogging(myBoolean) {
debugLogging = myBoolean;
}
export function setMetaData(myName, myVersion) {
metadata.name = myName;
metadata.version = myVersion;
}
export function myDebugLog(msg) {
if (debugLogging) {
log('' + logPrefix('[DEBUG]') + ' - ' + msg + '');
}
}
export function myErrorLog(e, msg) {
logError(e, '' + logPrefix('[ERROR]') + ' - ' + msg + '');
}
export function myLog(msg) {
log('' + logPrefix('') + '' + msg + '');
}
export function logPrefix(msg) {
let now = GLib.DateTime.new_now_local();
let nowString = now.format("%Y-%m-%d %H:%M:%S.%f");
return nowString + ' - ' + `${metadata.name} (V.${metadata.version})` + ' - ' + msg;
}