4
1
Fork 1

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 115bfe4d31
4 changed files with 15 additions and 11 deletions

View File

@ -1,9 +1,10 @@
FROM alpine:latest
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 && \
mkdir /opt/qbt && \
tar -zxf qbt-linux-alpine-x64-1.7.22315.1.tar.gz -C /opt/qbt && \
chmod a+x /opt/qbt/* && \
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"]

View File

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

View File

@ -12,7 +12,7 @@ def dt():
str = f'{date} | {time.strftime("%H:%M:%S")}'
return str
DEFAULT = [f'{dt()} LOG: ',f'{dt()} ERROR: ']
DEFAULT = ['{} LOG: ','{} ERROR: ']
ID = str(uuid.uuid1())[0:7]
FILE = f'{ID}.txt'
@ -24,42 +24,42 @@ def file(log):
logfile.close()
def start():
log1 = DEFAULT[0] + str(msg.get('l_create').format(FILE))
log2 = DEFAULT[0] + str(msg.get('l_start'))
log1 = DEFAULT[0].format(dt()) + str(msg.get('l_create').format(FILE))
log2 = DEFAULT[0].format(dt()) + str(msg.get('l_start'))
file(log2)
print(f'{log1}\n{log2}')
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)
print(log)
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)
print(log)
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)
print(log)
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)
print(log)
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)
print(log)
def errqbt():
log = DEFAULT[1] + str(msg.get('l_errqbt'))
log = DEFAULT[1].format(dt()) + str(msg.get('l_errqbt'))
file(log)
print(log)
def errtelebot():
log = DEFAULT[1] + str(msg.get('l_errtele'))
log = DEFAULT[1].format(dt()) + str(msg.get('l_errtele'))
file(log)
print(log)

View File

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