Bugfix: logging system

---
- now the time in the logs is parsed correctly
- Timezone env added to dockerfile | docker-compose
This commit is contained in:
trueold89 2023-11-08 00:52:13 +03:00
parent 47301c367e
commit d6cd7abdeb
Signed by: trueold89
GPG Key ID: C122E85DD49E6B30
4 changed files with 15 additions and 11 deletions

View File

@ -1,9 +1,10 @@
FROM alpine:latest FROM alpine:latest
COPY bot /opt/bot COPY bot /opt/bot
RUN apk update && apk add bash python3 py-pip wget icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib && pip install telebot RUN apk update && apk add tzdata bash python3 py-pip wget icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib && pip install telebot
RUN wget https://github.com/fedarovich/qbittorrent-cli/releases/download/v1.7.22315.1/qbt-linux-alpine-x64-1.7.22315.1.tar.gz && \ RUN wget https://github.com/fedarovich/qbittorrent-cli/releases/download/v1.7.22315.1/qbt-linux-alpine-x64-1.7.22315.1.tar.gz && \
mkdir /opt/qbt && \ mkdir /opt/qbt && \
tar -zxf qbt-linux-alpine-x64-1.7.22315.1.tar.gz -C /opt/qbt && \ tar -zxf qbt-linux-alpine-x64-1.7.22315.1.tar.gz -C /opt/qbt && \
chmod a+x /opt/qbt/* && \ chmod a+x /opt/qbt/* && \
ln -sf /opt/qbt/qbt /bin/qbt && ln -sf /opt/bot/bot.py /bin/bot ln -sf /opt/qbt/qbt /bin/qbt && ln -sf /opt/bot/bot.py /bin/bot
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["/bin/bot"] ENTRYPOINT ["/bin/bot"]

View File

@ -53,6 +53,7 @@ docker run \
-e QUSER="<YOUR_QBIT_USERNAME>" \ -e QUSER="<YOUR_QBIT_USERNAME>" \
-e QPASS="<YOUR_QBIT_PASSWORD>" \ -e QPASS="<YOUR_QBIT_PASSWORD>" \
-e LANG="YOUR_LANG" \ -e LANG="YOUR_LANG" \
-e TZ="Europe/Moscow" \
-d -it your_image_here -d -it your_image_here
``` ```
@ -76,6 +77,7 @@ services:
QUSER: "<YOUR_QBIT_USERNAME>" QUSER: "<YOUR_QBIT_USERNAME>"
QPASS: "<YOUR_QBIT_PASSWORD>" QPASS: "<YOUR_QBIT_PASSWORD>"
LANG: "<YOUR_LANG>" LANG: "<YOUR_LANG>"
TZ: "Europe/Moscow"
``` ```
```bash ```bash

View File

@ -12,7 +12,7 @@ def dt():
str = f'{date} | {time.strftime("%H:%M:%S")}' str = f'{date} | {time.strftime("%H:%M:%S")}'
return str return str
DEFAULT = [f'{dt()} LOG: ',f'{dt()} ERROR: '] DEFAULT = ['{} LOG: ','{} ERROR: ']
ID = str(uuid.uuid1())[0:7] ID = str(uuid.uuid1())[0:7]
FILE = f'{ID}.txt' FILE = f'{ID}.txt'
@ -24,42 +24,42 @@ def file(log):
logfile.close() logfile.close()
def start(): def start():
log1 = DEFAULT[0] + str(msg.get('l_create').format(FILE)) log1 = DEFAULT[0].format(dt()) + str(msg.get('l_create').format(FILE))
log2 = DEFAULT[0] + str(msg.get('l_start')) log2 = DEFAULT[0].format(dt()) + str(msg.get('l_start'))
file(log2) file(log2)
print(f'{log1}\n{log2}') print(f'{log1}\n{log2}')
def auth(name,id): def auth(name,id):
log = DEFAULT[0] + str(msg.get('l_auth').format(name,id)) log = DEFAULT[0].format(dt()) + str(msg.get('l_auth').format(name,id))
file(log) file(log)
print(log) print(log)
def add(name,id,folder,path): def add(name,id,folder,path):
log = DEFAULT[0] + str(msg.get('l_add').format(name,id,folder,path)) log = DEFAULT[0].format(dt()) + str(msg.get('l_add').format(name,id,folder,path))
file(log) file(log)
print(log) print(log)
def rm(name,id,folder): def rm(name,id,folder):
log = DEFAULT[0] + str(msg.get('l_rm').format(name,id,folder)) log = DEFAULT[0].format(dt()) + str(msg.get('l_rm').format(name,id,folder))
file(log) file(log)
print(log) print(log)
def addfile(name,id,filename): def addfile(name,id,filename):
log = DEFAULT[0] + str(msg.get('l_file').format(name,id,filename[9:])) log = DEFAULT[0].format(dt()) + str(msg.get('l_file').format(name,id,filename[9:]))
file(log) file(log)
print(log) print(log)
def addmagnet(name,id,link): def addmagnet(name,id,link):
log = DEFAULT[0] + str(msg.get('l_magnet').format(name,id,link)) log = DEFAULT[0].format(dt()) + str(msg.get('l_magnet').format(name,id,link))
file(log) file(log)
print(log) print(log)
def errqbt(): def errqbt():
log = DEFAULT[1] + str(msg.get('l_errqbt')) log = DEFAULT[1].format(dt()) + str(msg.get('l_errqbt'))
file(log) file(log)
print(log) print(log)
def errtelebot(): def errtelebot():
log = DEFAULT[1] + str(msg.get('l_errtele')) log = DEFAULT[1].format(dt()) + str(msg.get('l_errtele'))
file(log) file(log)
print(log) print(log)

View File

@ -14,3 +14,4 @@ services:
QUSER: "<YOUR_QBIT_USERNAME>" QUSER: "<YOUR_QBIT_USERNAME>"
QPASS: "<YOUR_QBIT_PASSWORD>" QPASS: "<YOUR_QBIT_PASSWORD>"
LANG: "<YOUR_LANG>" LANG: "<YOUR_LANG>"
TZ: "Europe/Moscow"