Skip to content

Commit

Permalink
fix(admin): fix /logs handler parse_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
exmanka committed Jan 30, 2024
1 parent ac66fcc commit e410535
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
container_name: tgbot-container
restart: unless-stopped
env_file:
- .env
- .confs/.data/.env
ports:
- 80:80
# - 443:443
Expand All @@ -30,12 +30,14 @@ services:
ADDITIONAL_LANGUAGE: ${ADDITIONAL_LANGUAGE}
container_name: postgres-container
restart: unless-stopped
environment:
TZ: ${TZ}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_INITDB_ARGS: ${POSTGRES_INITDB_ARGS}
env_file:
- .confs/.data/.env
# environment:
# TZ: ${TZ}
# POSTGRES_USER: ${POSTGRES_USER}
# POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
# POSTGRES_DB: ${POSTGRES_DB}
# POSTGRES_INITDB_ARGS: ${POSTGRES_INITDB_ARGS}
ports:
- 5432:5432
healthcheck:
Expand All @@ -48,7 +50,7 @@ services:
volumes:
- db-data:/var/lib/postgresql/data
- db-backups:/var/lib/postgresql/backups
- ./init-database.sql:/docker-entrypoint-initdb.d/init-database.sql
- .confs/.data/init-database.sql:/docker-entrypoint-initdb.d/init-database.sql

networks:
appnet:
Expand Down
5 changes: 3 additions & 2 deletions src/handlers/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import aiofiles
import html
from decimal import Decimal
from aiogram import Dispatcher
from aiogram.types import Message, CallbackQuery
Expand Down Expand Up @@ -432,7 +433,7 @@ async def show_logs(message: Message):
if last_rows_number_list:
last_rows_number = int(last_rows_number_list[0])
else:
last_rows_number = 25
last_rows_number = 50

# read only last rows of file
last_rows_counter = 0
Expand All @@ -453,7 +454,7 @@ async def show_logs(message: Message):
last_lines = (await f.read()).decode()

# set markdown YAML code block language because it has acceptable log file syntax highlighting
await message.answer(f"```yaml\n{last_lines}```", parse_mode='MarkdownV2')
await message.answer(f"<pre>{html.escape(last_lines)}</pre>", parse_mode='HTML')


@admin_mw.admin_only()
Expand Down

0 comments on commit e410535

Please sign in to comment.