Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Add custom color for twilio logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 23, 2019
1 parent 71b3e02 commit 001cfef
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -127,7 +127,7 @@ logging:
loggers:
mau:
level: DEBUG
fbchat:
twilio:
level: DEBUG
aiohttp:
level: INFO
Expand Down
2 changes: 1 addition & 1 deletion mautrix_twilio/twilio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


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
Expand Down
2 changes: 1 addition & 1 deletion mautrix_twilio/twilio/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


class TwilioHandler:
log: logging.Logger = logging.getLogger("mau.twilio")
log: logging.Logger = logging.getLogger("twilio.in")
app: web.Application
validator: RequestValidator

Expand Down
1 change: 1 addition & 0 deletions mautrix_twilio/util/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .color_log import ColorFormatter
25 changes: 25 additions & 0 deletions mautrix_twilio/util/color_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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)

0 comments on commit 001cfef

Please sign in to comment.