Make log directory if logging to file is on

This commit is contained in:
Иван Солнцев 2024-10-09 15:15:43 +03:00
parent cde5b599ef
commit 9f6043cc53
Signed by: johnsol
GPG key ID: C56B337609C9821E
2 changed files with 16 additions and 8 deletions

13
main.py
View file

@ -20,12 +20,13 @@ else:
if __name__ == "__main__": if __name__ == "__main__":
try: if config.SETUP["setup"]["log_to_file"]:
os.mkdir(os.path.join(os.getcwd(), "log")) try:
except OSError: os.mkdir(os.path.join(os.getcwd(), "log"))
log.debug("Directory \"log\" is exists") except OSError:
else: log.debug("Directory \"log\" is exists")
log.debug("Directory \"log\" created") else:
log.debug("Directory \"log\" created")
log.error("Attempt to start server...") log.error("Attempt to start server...")

View file

@ -1,12 +1,19 @@
import logging
from server.response import Response from server.response import Response
log = logging.getLogger(__name__)
def work(headers, request): def work(headers, request):
print(headers, request) log.debug("HEADER: %s", headers)
log.debug("REQUEST: %s", request)
return Response(data=b"Tested!") return Response(data=b"Tested!")
def work2(headers, get_request, post_request): def work2(headers, get_request, post_request):
print(headers, get_request, post_request) log.debug("HEADERS: %s", headers)
log.debug("REQUEST: %s", get_request)
log.debug("DATA: %s", post_request)
return Response(data=b"Pass") return Response(data=b"Pass")