изменение системы логирования
This commit is contained in:
+9
-9
@@ -4,7 +4,7 @@ import socket
|
||||
import aiofiles
|
||||
import call_handler
|
||||
import config
|
||||
import logging
|
||||
from main import logger
|
||||
|
||||
|
||||
def send_action(s, action):
|
||||
@@ -69,21 +69,21 @@ async def ami_listening():
|
||||
while True:
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
logging.info("Connecting to Asterisk...")
|
||||
logger.info("Connecting to Asterisk...")
|
||||
s.connect((config.AMI_HOST, config.AMI_PORT))
|
||||
break
|
||||
except ConnectionRefusedError:
|
||||
logging.warning("Connection refused. Retrying...")
|
||||
logger.warning("Connection refused. Retrying...")
|
||||
await asyncio.sleep(1)
|
||||
|
||||
logging.info("Connected to Asterisk")
|
||||
logging.info("Logging in...")
|
||||
logger.info("Connected to Asterisk")
|
||||
logger.info("Logging in...")
|
||||
|
||||
login_action = f"Action: Login\r\nUsername: {config.AMI_USER}\r\nSecret: {config.AMI_PASSWORD}\r\n\r\n"
|
||||
send_action(s, login_action)
|
||||
|
||||
logging.info("Logged in")
|
||||
logging.info("Listening for events...")
|
||||
logger.info("Logged in")
|
||||
logger.info("Listening for events...")
|
||||
|
||||
events_action = "Action: Events\r\nEventMask: on\r\n\r\n"
|
||||
send_action(s, events_action)
|
||||
@@ -96,9 +96,9 @@ async def ami_listening():
|
||||
if config.DEBUG:
|
||||
await full_log(event)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
logging.info("Exiting...")
|
||||
logger.info("Exiting...")
|
||||
s.close()
|
||||
daily_check_pending_task.cancel()
|
||||
except ConnectionResetError:
|
||||
logging.warning("Connection reset. Restarting...")
|
||||
logger.warning("Connection reset. Restarting...")
|
||||
await ami_listening()
|
||||
|
||||
Reference in New Issue
Block a user