Added Matrix support to Logger.
This commit is contained in:
@@ -11,6 +11,7 @@ import emoji
|
||||
from colorama import Fore, init
|
||||
|
||||
from TwitchChannelPointsMiner.classes.Discord import Discord
|
||||
from TwitchChannelPointsMiner.classes.Matrix import Matrix
|
||||
from TwitchChannelPointsMiner.classes.Settings import Events
|
||||
from TwitchChannelPointsMiner.classes.Telegram import Telegram
|
||||
from TwitchChannelPointsMiner.utils import remove_emoji
|
||||
@@ -71,7 +72,8 @@ class LoggerSettings:
|
||||
"color_palette",
|
||||
"auto_clear",
|
||||
"telegram",
|
||||
"discord"
|
||||
"discord",
|
||||
"matrix"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
@@ -88,6 +90,7 @@ class LoggerSettings:
|
||||
auto_clear: bool = True,
|
||||
telegram: Telegram or None = None,
|
||||
discord: Discord or None = None,
|
||||
matrix: Matrix or None = None
|
||||
):
|
||||
self.save = save
|
||||
self.less = less
|
||||
@@ -101,6 +104,7 @@ class LoggerSettings:
|
||||
self.auto_clear = auto_clear
|
||||
self.telegram = telegram
|
||||
self.discord = discord
|
||||
self.matrix = matrix
|
||||
|
||||
|
||||
class FileFormatter(logging.Formatter):
|
||||
@@ -171,6 +175,7 @@ class GlobalFormatter(logging.Formatter):
|
||||
if hasattr(record, "event"):
|
||||
self.telegram(record)
|
||||
self.discord(record)
|
||||
self.matrix(record)
|
||||
|
||||
if self.settings.colored is True:
|
||||
record.msg = (
|
||||
@@ -202,6 +207,20 @@ class GlobalFormatter(logging.Formatter):
|
||||
):
|
||||
self.settings.discord.send(record.msg, record.event)
|
||||
|
||||
def matrix(self, record):
|
||||
skip_discord = False if hasattr(
|
||||
record, "skip_matrix") is False else True
|
||||
|
||||
if (
|
||||
self.settings.matrix is not None
|
||||
and skip_matrix is False
|
||||
and self.settings.matrix.password
|
||||
!= "..."
|
||||
and self.settings.matrix.room_id
|
||||
!= "..."
|
||||
):
|
||||
self.settings.matrix.send(record.msg, record.event)
|
||||
|
||||
|
||||
def configure_loggers(username, settings):
|
||||
if settings.colored is True:
|
||||
|
||||
Reference in New Issue
Block a user