Commit 001cfef6 authored by Tulir Asokan's avatar Tulir Asokan 🐈

Add custom color for twilio logs

parent 71b3e026
Pipeline #253 passed with stages
in 1 minute and 1 second
......@@ -110,7 +110,7 @@ logging:
version: 1
formatters:
colored:
(): mautrix.util.color_log.ColorFormatter
(): mautrix_twilio.util.ColorFormatter
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
normal:
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
......@@ -127,7 +127,7 @@ logging:
loggers:
mau:
level: DEBUG
fbchat:
twilio:
level: DEBUG
aiohttp:
level: INFO
......
......@@ -24,7 +24,7 @@ from ..config import Config
class TwilioClient:
log: logging.Logger = logging.getLogger("mau.twilio.api")
log: logging.Logger = logging.getLogger("twilio.out")
base_url: str = "https://api.twilio.com/2010-04-01"
http: ClientSession
sender_id: TwilioUserID
......
......@@ -28,7 +28,7 @@ if TYPE_CHECKING:
class TwilioHandler:
log: logging.Logger = logging.getLogger("mau.twilio")
log: logging.Logger = logging.getLogger("twilio.in")
app: web.Application
validator: RequestValidator
......
from .color_log import ColorFormatter
# mautrix-twilio - A Matrix-Twilio relaybot bridge.
# Copyright (C) 2019 Tulir Asokan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from mautrix.util.color_log import ColorFormatter as BaseColorFormatter, PREFIX, RESET
TWILIO_COLOR = PREFIX + "35;1m" # magenta
class ColorFormatter(BaseColorFormatter):
def _color_name(self, module: str) -> str:
if module.startswith("twilio"):
return TWILIO_COLOR + module + RESET
return super()._color_name(module)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment