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"
if module.startswith(instance + "."):
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"
if module.startswith(loader + "."):
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) => {
entry.time = new Date(entry.time)
entry.nameSuffix = ""
if (entry.name.startsWith("maubot.")) {
entry.name = entry.name.substr("maubot.".length)
}
if (entry.name.startsWith("client.")) {
if (entry.name.startsWith("maubot.client.")) {
if (entry.name.endsWith(".crypto")) {
entry.name = entry.name.slice(0, -".crypto".length)
entry.nameSuffix = "/crypto"
}
entry.name = entry.name.substr("client.".length)
entry.nameLink = `/client/${entry.name}`
} else if (entry.name.startsWith("instance.")) {
entry.nameLink = `/instance/${entry.name.substr("instance.".length)}`
entry.name = `client/${entry.name.slice("maubot.client.".length)}`
entry.nameLink = `/${entry.name}`
} else if (entry.name.startsWith("maubot.instance.")) {
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}`
}
}