mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-02 02:26:00 +00:00
Using a custom logger with colors and timestamp instead of console.xxx
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
function _formatMessage(...args) {
|
||||
var t = Time.getFormattedTimestamp()
|
||||
if (args.length > 1) {
|
||||
var module = args.shift()
|
||||
return `\x1b[36m${t}\x1b[0m \x1b[35m[${module}]\x1b[0m ` + args.join(" ")
|
||||
} else {
|
||||
return `\x1b[36m${t}\x1b[0m ` + args.join(" ")
|
||||
}
|
||||
}
|
||||
|
||||
function log(...args) {
|
||||
var msg = _formatMessage(...args)
|
||||
console.log(msg)
|
||||
}
|
||||
|
||||
function warn(...args) {
|
||||
var msg = _formatMessage(...args)
|
||||
console.warn(msg)
|
||||
}
|
||||
|
||||
function error(...args) {
|
||||
var msg = _formatMessage(...args)
|
||||
console.error(msg)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user