uh, more logging?
This commit is contained in:
parent
fd05f39f4a
commit
bfa0534f6d
|
@ -12,7 +12,7 @@ from mastoposter.integrations import (
|
|||
)
|
||||
from mastoposter.types import Status
|
||||
|
||||
logger = getLogger(__name__)
|
||||
logger = getLogger()
|
||||
|
||||
|
||||
def load_integrations_from(config: ConfigParser) -> List[FilteredIntegration]:
|
||||
|
|
|
@ -37,6 +37,7 @@ async def listen(
|
|||
):
|
||||
logger.info("Starting listening...")
|
||||
async for status in source(**kwargs):
|
||||
logger.info("New status: %s", status.uri)
|
||||
logger.debug("Got status: %r", status)
|
||||
if status.account.id != user:
|
||||
logger.info(
|
||||
|
@ -91,6 +92,7 @@ def main(config_path: str):
|
|||
)
|
||||
account = Account.from_dict(rq.json())
|
||||
user_id = account.id
|
||||
|
||||
logger.info("account.id=%s", user_id)
|
||||
|
||||
url = "wss://{}/api/v1/streaming".format(conf["main"]["instance"])
|
||||
|
|
|
@ -11,7 +11,7 @@ from mastoposter.filters.text import TextFilter # NOQA
|
|||
from mastoposter.filters.spoiler import SpoilerFilter # NOQA
|
||||
from mastoposter.filters.visibility import VisibilityFilter # NOQA
|
||||
|
||||
logger = getLogger(__name__)
|
||||
logger = getLogger("filters")
|
||||
|
||||
|
||||
def run_filters(filters: List[FilterInstance], status: Status) -> bool:
|
||||
|
|
|
@ -12,7 +12,7 @@ class CombinedFilter(BaseFilter, filter_name="combined"):
|
|||
}
|
||||
|
||||
def __init__(self, filter_names: List[str], operator: str):
|
||||
self.filter_names = filter_names
|
||||
self._filter_names = filter_names
|
||||
self._operator_name = operator
|
||||
self.operator = self.OPERATORS[self._operator_name]
|
||||
self.filters: List[FilterInstance] = []
|
||||
|
@ -30,7 +30,7 @@ class CombinedFilter(BaseFilter, filter_name="combined"):
|
|||
super().post_init(filters, config)
|
||||
self.filters = [
|
||||
self.new_instance(name, config["filter/" + name.lstrip("~!")])
|
||||
for name in self.filter_names
|
||||
for name in self._filter_names
|
||||
]
|
||||
|
||||
def __call__(self, post: Status) -> bool:
|
||||
|
@ -39,7 +39,12 @@ class CombinedFilter(BaseFilter, filter_name="combined"):
|
|||
return self.operator([f[1](post) ^ f[0] for f in self.filters])
|
||||
|
||||
def __repr__(self):
|
||||
if self.filters:
|
||||
return (
|
||||
f"Filter:combined(op={self._operator_name}, "
|
||||
f"filters={self.filters!r})"
|
||||
)
|
||||
return (
|
||||
f"Filter:combined(op={self._operator_name}, "
|
||||
f"filters={self._filter_names!r}, loaded=False)"
|
||||
)
|
||||
|
|
|
@ -11,7 +11,7 @@ from mastoposter.integrations.discord.types import (
|
|||
)
|
||||
from mastoposter.types import Status
|
||||
|
||||
logger = getLogger(__name__)
|
||||
logger = getLogger("integrations.discord")
|
||||
|
||||
|
||||
class DiscordIntegration(BaseIntegration):
|
||||
|
|
|
@ -9,7 +9,7 @@ from mastoposter.types import Attachment, Poll, Status
|
|||
from emoji import emojize
|
||||
|
||||
|
||||
logger = getLogger(__name__)
|
||||
logger = getLogger("integrations.telegram")
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -93,7 +93,7 @@ class TelegramIntegration(BaseIntegration):
|
|||
)
|
||||
if not response.ok:
|
||||
logger.error("TG error: %r", response.error)
|
||||
logger.info("parameters: %r", kwargs)
|
||||
logger.error("parameters: %r", kwargs)
|
||||
return response
|
||||
|
||||
async def _post_plaintext(self, text: str) -> TGResponse:
|
||||
|
@ -135,6 +135,11 @@ class TelegramIntegration(BaseIntegration):
|
|||
if attachment.type not in allowed_medias:
|
||||
continue
|
||||
if attachment.type not in MEDIA_COMPATIBILITY:
|
||||
logger.warning(
|
||||
"attachment %r is not in %r",
|
||||
attachment.type,
|
||||
MEDIA_COMPATIBILITY,
|
||||
)
|
||||
continue
|
||||
allowed_medias &= MEDIA_COMPATIBILITY[attachment.type]
|
||||
media_list.append(
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from configparser import ConfigParser
|
||||
from html import escape
|
||||
from logging import getLogger
|
||||
from typing import Callable, Dict
|
||||
from bs4.element import Tag, PageElement
|
||||
|
||||
logger = getLogger("utils")
|
||||
|
||||
|
||||
def md_escape(text: str) -> str:
|
||||
return (
|
||||
|
@ -24,9 +27,13 @@ def normalize_config(conf: ConfigParser):
|
|||
normalized_key = k.replace(" ", "_").replace("-", "_")
|
||||
if k == normalized_key:
|
||||
continue
|
||||
logger.info(
|
||||
"moving %r.%r -> %r.%r", section, k, section, normalized_key
|
||||
)
|
||||
conf[section][normalized_key] = v
|
||||
_remove.add(k)
|
||||
for k in _remove:
|
||||
logger.info("removing key %r.%r", section, k)
|
||||
del conf[section][k]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue