Files
brave-core/tools/cr/incendiary_error_handler.py
T
cdesouza-chromium ede32a7653 [canary][plaster] Modularise some of Brockit for reuse (#28430)
This PR breaks some of the components of brockit into their own files
for reuse in a plaster prototype.

Resolves https://github.com/brave/brave-browser/issues/45113
2025-04-01 19:05:01 +01:00

27 lines
942 B
Python

# Copyright (c) 2025 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.
import logging
from rich.logging import RichHandler
from terminal import console
class IncendiaryErrorHandler(RichHandler):
""" A custom handler that adds emojis to error messages.
"""
def emit(self, record: logging.LogRecord) -> None:
if record.levelno == logging.ERROR:
record.msg = f\\_(ツ)_/¯\n🔥🔥 {record.msg}'
elif record.levelno == logging.DEBUG:
# Debug messages should be printed as normal logs, otherwise the
# formatting goes all over the place with the status bar.
console.log(f'[dim]{record.getMessage()}[/]', _stack_offset=8)
return
super().emit(record)