Improve log coloring

This commit is contained in:
Tulir Asokan 2022-03-26 15:48:46 +02:00
parent 4685c492a9
commit 32688372fe
2 changed files with 13 additions and 8 deletions

View file

@ -38,6 +38,9 @@ class ColorFormatter(BaseColorFormatter):
instance = "maubot.instance" instance = "maubot.instance"
if module.startswith(instance + "."): if module.startswith(instance + "."):
return f"{MAU_COLOR}{instance}{RESET}.{INST_COLOR}{module[len(instance) + 1:]}{RESET}" return f"{MAU_COLOR}{instance}{RESET}.{INST_COLOR}{module[len(instance) + 1:]}{RESET}"
instance_db = "maubot.instance_db"
if module.startswith(instance_db + "."):
return f"{MAU_COLOR}{instance_db}{RESET}.{INST_COLOR}{module[len(instance_db) + 1:]}{RESET}"
loader = "maubot.loader" loader = "maubot.loader"
if module.startswith(loader + "."): if module.startswith(loader + "."):
return f"{MAU_COLOR}{instance}{RESET}.{LOADER_COLOR}{module[len(loader) + 1:]}{RESET}" return f"{MAU_COLOR}{instance}{RESET}.{LOADER_COLOR}{module[len(loader) + 1:]}{RESET}"

View file

@ -95,18 +95,20 @@ class Dashboard extends Component {
const processEntry = (entry) => { const processEntry = (entry) => {
entry.time = new Date(entry.time) entry.time = new Date(entry.time)
entry.nameSuffix = "" entry.nameSuffix = ""
if (entry.name.startsWith("maubot.")) { if (entry.name.startsWith("maubot.client.")) {
entry.name = entry.name.substr("maubot.".length)
}
if (entry.name.startsWith("client.")) {
if (entry.name.endsWith(".crypto")) { if (entry.name.endsWith(".crypto")) {
entry.name = entry.name.slice(0, -".crypto".length) entry.name = entry.name.slice(0, -".crypto".length)
entry.nameSuffix = "/crypto" entry.nameSuffix = "/crypto"
} }
entry.name = entry.name.substr("client.".length) entry.name = `client/${entry.name.slice("maubot.client.".length)}`
entry.nameLink = `/client/${entry.name}` entry.nameLink = `/${entry.name}`
} else if (entry.name.startsWith("instance.")) { } else if (entry.name.startsWith("maubot.instance.")) {
entry.nameLink = `/instance/${entry.name.substr("instance.".length)}` entry.name = `instance/${entry.name.slice("maubot.instance.".length)}`
entry.nameLink = `/${entry.name}`
} else if (entry.name.startsWith("maubot.instance_db.")) {
entry.nameSuffix = "/db"
entry.name = `instance/${entry.name.slice("maubot.instance_db.".length)}`
entry.nameLink = `/${entry.name}`
} }
} }