Skip to content

Commit

Permalink
harmonize logging
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias <[email protected]>
  • Loading branch information
call-me-matt committed Feb 16, 2025
1 parent 2c46ec1 commit 5a43e94
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion connectors/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def post(self):
self.logger.info(f"...posting on bluesky...")
self.logger.info(f"...posting on bluesky")

# log in to bluesky.social
try:
Expand Down
8 changes: 4 additions & 4 deletions connectors/forum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def post(self):
# only one message per language, as multiple posts with same text are rejected from forum

self.logger.info(
f"...community forum post to https://community.openstreetmap.org/t/-/{self.forum_to}."
f"...community forum post to https://community.openstreetmap.org/t/-/{self.forum_to}"
)

try:
Expand All @@ -34,9 +34,9 @@ def post(self):

response = requests.post(FORUM_API, json=data, headers=headers)

self.logger.info(f"Status Code {response.status_code}")
self.logger.info(f"...status code {response.status_code}")
self.logger.debug(f"JSON Response: {response.json()}")

except:
self.logger.error("failed to publish")
except Exception as e:
self.logger.error(f"failed to publish - {e}")
traceback.print_exc()
2 changes: 1 addition & 1 deletion connectors/josm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def post(self):
self.logger.info(f"...posting to josm...")
self.logger.info(f"...posting to josm")

with xmlrpc.client.ServerProxy(
f"https://{self.josm_USER}:{self.josm_PW}@josm.openstreetmap.de/login/xmlrpc"
Expand Down
2 changes: 1 addition & 1 deletion connectors/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def post(self):
server.login(self.mail_USER, self.mail_PW)
server.sendmail(self.mail_from, TO, msg.as_string())
server.close()
self.logger.info("successfully sent the mail to " + ", ".join(TO))
self.logger.info("...sent mail to " + ", ".join(TO))
except:
self.logger.error("failed to send mail")
traceback.print_exc()
Expand Down
6 changes: 3 additions & 3 deletions connectors/mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def post(self):

for recipient in self.mastodon_to:

self.logger.info(f"...toot to {recipient}...")
self.logger.info(f"...toot to {recipient}")

media = None
# upload picture if applicable
Expand All @@ -36,12 +36,12 @@ def post(self):
mastodon.me().id, pinned=True
):
self.logger.info(
f"unpinning previous toot {pinned_toot.id}"
f"...unpinning previous toot {pinned_toot.id}"
)
resp = mastodon.status_unpin(pinned_toot.id)
self.logger.debug(f"{resp}")
resp = mastodon.status_pin(toot.id)
self.logger.info(f"pinned toot")
self.logger.info(f"...pinned toot")
self.logger.debug(f"{resp}")
except Exception as e:
self.logger.error("failed to pin mastodon status:")
Expand Down
7 changes: 4 additions & 3 deletions connectors/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


async def post(self):
self.logger.info("...posting to matrix...")

try:
client = ClientAPI(
Expand All @@ -12,9 +11,11 @@ async def post(self):
self.logger.error(f"could not connect to matrix chat - {e}")
return
for recipient in self.matrix_to:
self.logger.info(recipient)
self.logger.info(f"...posting to matrix chat: {recipient}")
try:
await client.send_text(recipient, self.tw_text)
except Exception as e:
self.logger.error(f"could not send matrix chat message- {e}")
self.logger.error(
f"could not send matrix chat message to {recipient} - {e}"
)
await client.api.session.close()
2 changes: 1 addition & 1 deletion connectors/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def post(self):
return

for recipient in self.telegram_to:
self.logger.info(f"...telegramming {recipient}...")
self.logger.info(f"...telegramming {recipient}")

try:
resp = bot.sendMessage(int(recipient), self.tw_text)
Expand Down
2 changes: 1 addition & 1 deletion connectors/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def post(self):
self.logger.info("...tweet...")
self.logger.info("...tweet")

try:
auth = tweepy.OAuthHandler(self.tw_CONSUMER_KEY, self.tw_CONSUMER_SECRET)
Expand Down

0 comments on commit 5a43e94

Please sign in to comment.