refactor(core): logging setup and session path
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
@@ -7,6 +8,17 @@ from modules.telegram import TelegramStarsBot
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_logging():
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler("logs/bot.log", encoding="utf-8"),
|
||||
logging.StreamHandler(),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
async def main():
|
||||
try:
|
||||
config = Config()
|
||||
@@ -21,14 +33,8 @@ async def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler("logs/bot.log", encoding="utf-8"),
|
||||
logging.StreamHandler(),
|
||||
],
|
||||
)
|
||||
os.makedirs("logs", exist_ok=True)
|
||||
setup_logging()
|
||||
|
||||
try:
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user