Feat: Debug logger

This commit is contained in:
Taso committed 2021-01-13 20:31:14 -05:00
1 parent 7b9d8826a6
commit d56112a0cb
2 files changed
+34

No files matched your search

+4
View File
@@ -18,6 +18,10 @@
"ringtone": "pixel",
"ringtoneVol": 100
},
"debug": {
"printDebugLogs": true,
"logLevel": 1
},
"frames": ["default.png", "s10.png", "tw.png", "samsung.png"],
"zoomOptions": ["120%", "100%", "80%", "60%", "40%"],
"ringtones": ["marimba", "pixel"],
+30
View File
@@ -0,0 +1,30 @@
import config from '../../config/default.json';
interface DebugEvent {
action?: string;
level?: number;
data: any;
}
/**
* Send an event and debug content for the logger according to the config values found in the
* `config/default.json`. Lower log level means more verbose logs.
*
* @param event A debug log object
* @param event.name The name of the event to log
* @param event.level The level of this debug log (1-5 ideally)
* @param event.content The content of whatever
**/
function LogDebugEvent(event: DebugEvent) {
const logLevel = event.level || 1;
const name = event.action || 'Undefined action';
if (config.debug.printDebugLogs && logLevel >= config.debug.logLevel) {
console.group(`${name} | Level: ${logLevel}`);
console.dir(event.data);
console.groupEnd();
}
}
export default LogDebugEvent;