mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
Feat: Debug logger
This commit is contained in:
1 parent
7b9d8826a6
commit
d56112a0cb
2 files changed
+34
No files matched your search
@@ -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"],
|
||||
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user