774056846 4 ay önce
ebeveyn
işleme
71f3916c56

+ 10 - 11
src/core/callcenter/acd.py

@@ -35,22 +35,22 @@ class AcdService:
             return
         call_info.answer_flag = AnswerFlag.TRANSFER_TO_AGENT.code
         self.cache.add_call_info(call_info)
-        print('debugger::transfer_to_agent, come in ', flush=True)
+        self.logger.info('debugger::transfer_to_agent, come in ')
         # 1. hold住并且播放等待音
         self.call_service.hold(call_info, device_id)
-        print('debugger::transfer_to_agent, 1111111 ', flush=True)
+        self.logger.info('debugger::transfer_to_agent, 1111111 ')
         # 获得空闲坐席
         agent_number = self.agent_service.assign(AgentActionRequest(saas_id=saasId, service_id=service_id))
-        print('debugger::transfer_to_agent, 222222 %s'%agent_number, flush=True)
+        self.logger.info('debugger::transfer_to_agent, 222222 %s'%agent_number)
         if not agent_number:
             # 如果没有空闲坐席,播放等待音
-            print("AcdService transferToAgent agentNumber is empty serviceId:%s,called:%s,callId:%s"%(
-                             service_id, call_info.called, call_info.call_id), flush=True)
+            self.logger.info("AcdService transferToAgent agentNumber is empty serviceId:%s,called:%s,callId:%s"%(
+                             service_id, call_info.called, call_info.call_id))
             self.add_acd_queue(call_info, service_id)
         else:
             # 有空闲坐席,直接转接
-            print("AcdService transferToAgent agentNumber not empty %s, serviceId:%s,called:%s,callId:%s"%(
-                             agent_number, service_id, call_info.called, call_info.call_id), flush=True)
+            self.logger.info("AcdService transferToAgent agentNumber not empty %s, serviceId:%s,called:%s,callId:%s"%(
+                             agent_number, service_id, call_info.called, call_info.call_id))
             self.call_service.transfer(call_info, agent_number, service_id)
 
     def try_transfer_agent(self):
@@ -76,12 +76,11 @@ class AcdService:
                 continue
             agent_number = self.agent_service.assign(AgentActionRequest(saas_id=saasId, service_id=task_service_id))
             if not agent_number:
-                print("AcdService tryTransferAgent agentNumber is Empty %s"% call_id, flush=True)
+                self.logger.info("AcdService tryTransferAgent agentNumber is Empty %s"% call_id)
                 tmp_arr.append(call_id)
                 continue
-            print(
-                "AcdService tryTransferAgent agentNumber not Empty %s, serviceId:%s, called:%s, callId:%s"%(agent_number, task_service_id, call_info.called, call_id),
-                flush=True
+            self.logger.info(
+                "AcdService tryTransferAgent agentNumber not Empty %s, serviceId:%s, called:%s, callId:%s"%(agent_number, task_service_id, call_info.called, call_id)
                 )
             self.call_service.transfer(call_info, agent_number, task_service_id)
 

+ 8 - 8
src/core/callcenter/agent.py

@@ -373,7 +373,7 @@ class AgentMonitorService:
         agent_monitor.service_state = AgentServiceState.LOGOUT.code
         agent_monitor.heart_state = AgentHeartState.DEFAULT.code
         agent_monitor.heart_time = datetime.utcnow()
-        print("update_checkout", agent_monitor.check_out_time)
+        self.logger.info("update_checkout", agent_monitor.check_out_time)
         db.session.commit()
 
     def update_idle(self, agent_monitor):
@@ -498,14 +498,14 @@ class AgentStateService:
     def idle(self, saas_id, agent_id, phone_num):
         human_service = _get_human_service_service(saas_id, agent_id)
         if human_service is None:
-            print(f"agent engine idle not have human service {saas_id} {agent_id}")  # 使用print替代log
+            self.logger.info(f"agent engine idle not have human service {saas_id} {agent_id}")  # 使用print替代log
             return
         self.idle_hash(saas_id, agent_id, phone_num, human_service.service_id)
 
     def busy(self, saas_id, agent_id, phone_num):
         human_service = _get_human_service_service(saas_id, agent_id)
         if human_service is None:
-            print(f"agent engine busy not hava human service {saas_id} {agent_id}")  # 使用print替代log
+            self.logger.info(f"agent engine busy not hava human service {saas_id} {agent_id}")  # 使用print替代log
             return
         self.busy_hash(saas_id, agent_id, phone_num, human_service.service_id)
 
@@ -548,7 +548,7 @@ class AgentStateService:
 
     def assign_agent(self, saas_id, service_id, called=None, ivr_id=None, task_id=None, cbp=None):
         choose_phone_num = ''
-        print("assignAgent %s %s %s"% (saas_id, service_id, called), flush=True)
+        self.logger.info("assignAgent %s %s %s"% (saas_id, service_id, called))
         idle_agents = self.idle_agents(saas_id, service_id)
         if len(idle_agents) <= 0:
             return choose_phone_num
@@ -572,13 +572,13 @@ class AgentStateService:
         if not cache_agent_list:
             return []
         agent_str = '\n'.join(["%s-%s-%s-%s"%(x.phone_num, x.status, x.time, x.assign_time) for x in cache_agent_list])
-        print("assignAgent %s %s idleAgents:%s "% (saas_id, service_id, agent_str), flush=True)
+        self.logger.info("assignAgent %s %s idleAgents:%s "% (saas_id, service_id, agent_str))
         return self.get_idle_agents(cache_agent_list)
 
     def idle_hash(self, saas_id, agent_id, phone_num, service_id):
         key = self._key(saas_id, service_id)
         state_data = AgentStateData()
-        print("idle_hash, key=%s, saas_id=%s, phone_num=%s"%(key, saas_id, phone_num), flush=True)
+        self.logger.info("idle_hash, key=%s, saas_id=%s, phone_num=%s"%(key, saas_id, phone_num))
         cache_agent_map = self.get_cache_agent_map(saas_id, service_id)
         if cache_agent_map and phone_num in cache_agent_map:
             state_data = cache_agent_map[phone_num]
@@ -612,7 +612,7 @@ class AgentStateService:
     def get_cache_agent_list(self, saas_id, service_id):
         redis_key = self._key(saas_id, service_id)
         map_cache_by_key = self.redis_handler.redis.hgetall(redis_key)
-        print("get_cache_agent_list, redis_key=%s, map_cache_by_key=%s"%(redis_key, map_cache_by_key), flush=True)
+        self.logger.info("get_cache_agent_list, redis_key=%s, map_cache_by_key=%s"%(redis_key, map_cache_by_key))
         if not map_cache_by_key:  # 检查字典是否为空
             return []  # 返回空列表
 
@@ -717,7 +717,7 @@ def _get_newest_agent_number(saas_id):
 def _get_agent_monitor(saas_id, agent_number):
     monitor = AgentMonitor.query.filter(AgentMonitor.saas_id == saas_id,
                                         AgentMonitor.agent_num == agent_number).first()
-    print('_get_agent_monitor', saas_id, agent_number, monitor)
+    self.logger.info('_get_agent_monitor', saas_id, agent_number, monitor)
     return monitor
 
 

+ 5 - 4
src/core/callcenter/cache.py

@@ -18,17 +18,18 @@ class Cache:
         self.cacheDay = 7
         self.deviceCall = {}
         self.deviceUserPart = {}
+        self.logger = app.logger
         self.redis_handler = RedisHandler()
         self.dataHandleServer = DataHandleServer(app)
 
     def get_agent_info(self, saas_id, agent_number):
         text = self.redis_handler.get(AGENT_INFO + saas_id + ":" + agent_number)
-        print('get_agent_info', saas_id, agent_number, text, flush=True)
+        self.logger.info('get_agent_info', saas_id, agent_number, text)
         if text:
             return AgentInfo.from_json(text)
         phone = self.dataHandleServer.get_agent_phone(saas_id, agent_number)
         agent_info = AgentInfo(saas_id=saas_id, sip_server=phone.sip_server, agent_number=agent_number)
-        print('get_agent_info', saas_id, agent_number, agent_info, flush=True)
+        self.logger.info('get_agent_info', saas_id, agent_number, agent_info)
         self.add_agent_info(agent=agent_info)
         sys.stdout.flush()  # 强制刷新输出缓冲区
         return agent_info
@@ -63,7 +64,7 @@ class Cache:
     def add_call_info(self, call: CallInfo):
         for k, v in call.device_info_map.items():
             self.add_device(k, call.call_id)
-        # print('add_call_info', call.call_id, call, flush=True)
+        # self.logger.info('add_call_info', call.call_id, call)
         self.redis_handler.set(CALL_INFO + call.call_id, call.to_json_string(), self.cacheDay * 24 * 60 * 60)
 
 
@@ -78,7 +79,7 @@ class Cache:
         text = None
         if call_id:
             text = self.redis_handler.get(CALL_INFO + call_id)
-            # print('get_call_info', call_id, text)
+            # self.logger.info('get_call_info', call_id, text)
             # sys.stdout.flush()  # 强制刷新输出缓冲区
         if text:
             return CallInfo.from_json(text)

+ 5 - 5
src/core/callcenter/call.py

@@ -26,8 +26,8 @@ class CallService:
         device_id = 'D' + str(self.snowflake.next_id())
         # now = lambda: int(round(time.time() * 1000))
         now = datetime.utcnow().timestamp()
-        print("CallService 人工外呼 agent:%s makecall, ctiFlowId:%s, callId:%s, callerDisplay:%s, called:%s"%
-              (request.caller, request.cti_flow_id, call_id, request.caller_display, request.called), flush=True)
+        self.logger.info("CallService 人工外呼 agent:%s makecall, ctiFlowId:%s, callId:%s, callerDisplay:%s, called:%s"%
+              (request.caller, request.cti_flow_id, call_id, request.caller_display, request.called))
 
         agent = self.cache.get_agent_info(request.saas_id, request.agent_id)
         route_gateway = self.cache.get_route_gateway(request.saas_id)
@@ -69,12 +69,12 @@ class CallService:
         except:
             pass
         custom_device_id = devices[0]
-        print('debugger::hold, custom_device_id=%s'%custom_device_id, flush=True)
+        self.logger.info('debugger::hold, custom_device_id=%s'%custom_device_id)
         # self.client.sync_invoke_method("bridge_break", method_args=(custom_device_id,))
         # self.client.sync_invoke_method("hold_play", method_args=(custom_device_id,HOLD_MUSIC_PATH))
         self.client.bridge_break(call_info.call_id, custom_device_id)
         self.cache.set_need_play_hold_music(call_info.call_id)
-        print('debugger::hold success custom_device_id=%s'%custom_device_id, flush=True)
+        self.logger.info('debugger::hold success custom_device_id=%s'%custom_device_id)
 
     def cancel_hold(self, call_info: CallInfo, device_id):
         self.client.bridge_call(call_info.call_id, call_info.device_list[0], call_info.device_list[1])
@@ -95,7 +95,7 @@ class CallService:
         call_info.device_info_map[device_id] = device_info
         call_info.next_commands.append(NextCommand(device_info.device_id, NextType.NEXT_TRANSFER_CALL.code, call_info.device_list[0]))
         call_info.agent_key = agent_number
-        print('lwdebugger::transfer, agent_number=%s, device_id=%s, call_info=%s'% (agent_number, device_id, call_info), flush=True)
+        self.logger.info('lwdebugger::transfer, agent_number=%s, device_id=%s, call_info=%s'% (agent_number, device_id, call_info))
         # agent.sip_server
         self.cache.add_call_info(call_info)
         self.cache.add_agent_info(agent=agent, call_id=call_id, device_id=device_id)

+ 15 - 16
src/core/callcenter/esl/client.py

@@ -106,11 +106,11 @@ class InboundClient:
             random_index = abs(mmh3.hash(random_id)) % len(self.executors)
         else:
             random_index = random.randint(0, len(self.executors) - 1) if self.executors else 0
-        # print('choose_thread_pool_executor.index=', random_index, call_id, device_id, wdh_device_id)
+        # self.logger.info('choose_thread_pool_executor.index=', random_index, call_id, device_id, wdh_device_id)
         return self.executors.get(random_index)
 
     def process_esl_event(self, e):
-        # print(json.loads(e.serialize('json')))
+        # self.logger.info(json.loads(e.serialize('json')))
         event_name = EslEventUtil.getEventName(e)
         coreUUID = EslEventUtil.getCoreUuid(e)
         address = self.host + ':' + self.port
@@ -209,7 +209,7 @@ class InboundClient:
             profile = self.expression(profile2, params)
             builder.append(f"{profile}{PARK}")
         cmd = "".join(builder)
-        print(cmd, flush=True)
+        self.logger.info(cmd)
         self.con.bgapi(ORIGINATE, cmd)
 
     def call_timeout(self, call_id, device_id, timeout):
@@ -257,13 +257,13 @@ class InboundClient:
         try:
             _con = ESL.ESLconnection(self.host, self.port, self.password)
             if _con.connected():
-                print("hangup_call挂机1 hangup call: %s, device: %s, ctiCauseEnum: %s" % (call_id, device_id, case_enum), flush=True)
+                self.logger.info("hangup_call挂机1 hangup call: %s, device: %s, ctiCauseEnum: %s" % (call_id, device_id, case_enum))
                 arg = ''.join([EslEventUtil.SIP_H_P_LIBRA_HANGUP_CAUSE, "=", case_enum.description])
-                print("hangup_call挂机2 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
+                self.logger.info("hangup_call挂机2 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg))
                 self.send_args(device_id, SET, arg, con=_con)
-                print("hangup_call挂机3 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
+                self.logger.info("hangup_call挂机3 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg))
                 _con.sendEvent(msg)
-                print("hangup_call挂机4 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
+                self.logger.info("hangup_call挂机4 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg))
         except:
             traceback.print_exc()
         finally:
@@ -417,8 +417,7 @@ class InboundClient:
             _con = ESL.ESLconnection(self.host, self.port, self.password)
             if _con.connected():
                 e = _con.api(command, arg)
-                print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' ' + arg, e.serialize('json')),
-                      flush=True)
+                self.logger.info('debugger::%s success, arg=%s, event=%s' % (desc, command + ' ' + arg, e.serialize('json')))
         except:
             traceback.print_exc()
         finally:
@@ -431,7 +430,7 @@ class InboundClient:
             _con = ESL.ESLconnection(self.host, self.port, self.password)
             if _con.connected():
                 e = _con.bgapi(command, arg)
-                print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' '+arg, e.serialize('json')), flush=True)
+                self.logger.info('debugger::%s success, arg=%s, event=%s' % (desc, command + ' '+arg, e.serialize('json')))
         except:
             traceback.print_exc()
         finally:
@@ -453,7 +452,7 @@ class InboundClient:
 
     def show_channel(self, device_id):
         msg = self.con.api("show", " channels like " + device_id + " as json")
-        print('show_channel::', msg)
+        self.logger.info('show_channel::', msg)
         return msg
 
     def expression(self, template, params):
@@ -517,7 +516,7 @@ class OutboundClient:
                 if con.connected():
                     info = con.getInfo()
 
-                    # print(json.loads(info.serialize('json')))
+                    # self.logger.info(json.loads(info.serialize('json')))
                     event_name = info.getHeader("Event-Name")
                     device_id = info.getHeader("unique-id")
                     caller_number = info.getHeader("Caller-Caller-ID-Number")  # 获取来电号码
@@ -563,7 +562,7 @@ class OutboundClient:
                     # msg.addHeader("execute-app-arg", destination)
                     # # 发送消息以执行 bridge 操作
                     # con.sendEvent(msg)
-                    # print(f"Call {uuid} is bridged to {destination}")
+                    # self.logger.info(f"Call {uuid} is bridged to {destination}")
 
                     # con.execute("answer", "", uuid)
 
@@ -571,7 +570,7 @@ class OutboundClient:
                     # try:
                     #     con.disconnect()
                     # except:
-                    #     print('come in ')
+                    #     self.logger.info('come in ')
                     #     traceback.print_exc()
                 else:
                     self.server.logger.info("Failed to connect to FreeSWITCH")
@@ -598,7 +597,7 @@ class OutboundClient:
             call_info.device_list.append(new_device_id)
             # call_info.next_commands.append(NextCommand(device_id, NextType.NEXT_CALL_BRIDGE.code, new_device_id))
             call_info.device_info_map = {device_id: device_custom, new_device_id: device_bot}
-            print("lwdebugger::outBound, call_info=%s"%(call_info), flush=True)
+            self.server.logger.info("lwdebugger::outBound, call_info=%s"%(call_info))
             self.server.cache.add_call_info(call_info)
 
 
@@ -616,5 +615,5 @@ class OutboundClient:
         # HOST, PORT = "0.0.0.0", 8084
         # 创建一个 TCP 服务器
         with self.CustomTCPServer((HOST, PORT), self.ESLRequestHandler, agent, self.app, self.load_whitelist, self.load_agent_monitor,self.dataHandleServer) as server:
-            self.logger.info(f"ESL server listening on {HOST}:{PORT}")
+            print(f"ESL server listening on {HOST}:{PORT}")
             server.serve_forever()

+ 8 - 8
src/core/callcenter/esl/handler/channel_answer_handler.py

@@ -27,7 +27,7 @@ class ChannelAnswerHandler(EslEventHandler):
     def handle(self, address, event, coreUUID):
         call_id = EslEventUtil.getCallId(event)
         call_info = self.cache.get_call_info(call_id)
-        # print("lwdebugger::answer call_id:%s, call_info:%s, event:%s"% (call_id, call_info, json.loads(event.serialize('json'))), flush=True)
+        # self.logger.info("lwdebugger::answer call_id:%s, call_info:%s, event:%s"% (call_id, call_info, json.loads(event.serialize('json'))))
         if not call_info:
             return
 
@@ -35,7 +35,7 @@ class ChannelAnswerHandler(EslEventHandler):
         device_info = call_info.device_info_map.get(device_id)
         next_command = call_info.next_commands[0] if len(call_info.next_commands) > 0 else None
         device_type = DeviceType.get_by_code(device_info.device_type)
-        print("lwdebugger::ChannelAnswerHandler call_id:%s, device_id:%s, device_type:%s, next_command:%s"%(call_id, device_id, device_type, next_command), flush=True)
+        self.logger.info("lwdebugger::ChannelAnswerHandler call_id:%s, device_id:%s, device_type:%s, next_command:%s"%(call_id, device_id, device_type, next_command))
         if not next_command:
             return
 
@@ -76,7 +76,7 @@ class ChannelAnswerHandler(EslEventHandler):
         new_device_id = 'D' + str(self.snowflake.next_id())
         call.device_list.append(new_device_id)
         called = call.called
-        print("呼另外一侧电话: callId: %s, display:%s, called:%s, deviceId: %s "%(call_id, call.called_display, called, device_id), flush=True)
+        self.logger.info("呼另外一侧电话: callId: %s, display:%s, called:%s, deviceId: %s "%(call_id, call.called_display, called, device_id))
 
         # now = lambda: int(round(time.time() * 1000))
         now = datetime.utcnow().timestamp()
@@ -87,7 +87,7 @@ class ChannelAnswerHandler(EslEventHandler):
                                 call_time=now, device_type=DeviceType.CUSTOMER.code, caller_display=route_gateway.name, cdr_type=CdrType.OUTBOUND.code)
         call.next_commands.append(NextCommand(device_id=device_id, next_type=NextType.NEXT_CALL_BRIDGE.code, next_value=new_device_id))
         call.device_info_map[new_device_id] = new_device
-        # print("lwdebugger::call_other, call_info=%s"%call, flush=True)
+        # self.logger.info("lwdebugger::call_other, call_info=%s"%call)
         self.cache.add_call_info(call)
         self.cache.add_agent_info(agent=agent, call_id=call_id, device_id=device_id)
 
@@ -97,8 +97,8 @@ class ChannelAnswerHandler(EslEventHandler):
         self.inbound_client.make_call_new(context)
 
     def call_bridge(self, call: CallInfo, device: DeviceInfo, next_command: NextCommand, event):
-        print("开始桥接电话: callId:%s, caller:%s, called:%s, device1:%s, device2:%s"% (call.call_id,
-                         call.caller, call.called, next_command.device_id, next_command.next_value), flush=True)
+        self.logger.info("开始桥接电话: callId:%s, caller:%s, called:%s, device1:%s, device2:%s"% (call.call_id,
+                         call.caller, call.called, next_command.device_id, next_command.next_value))
         device1 = call.device_info_map.get(next_command.device_id)
         device2 = call.device_info_map.get(next_command.next_value)
 
@@ -115,9 +115,9 @@ class ChannelAnswerHandler(EslEventHandler):
         from_device_id = next_command.device_id
         device_id = EslEventUtil.getDeviceId(event)
         call.next_commands.append(NextCommand(device_id, NextType.NEXT_TRANSFER_SUCCESS.code, call.device_list[1]))
-        print("转接电话中 callId:%s, from:%s, to:%s "% (call.call_id, from_device_id, device_id), flush=True)
+        self.logger.info("转接电话中 callId:%s, from:%s, to:%s "% (call.call_id, from_device_id, device_id))
         self.inbound_client.transfer_call(device_id, next_command.next_value)
-        print("转接完成 callId:%s, from:%s, to:%s "% (call.call_id, device_id, call.device_list[0]), flush=True)
+        self.logger.info("转接完成 callId:%s, from:%s, to:%s "% (call.call_id, device_id, call.device_list[0]))
         self.inbound_client.bridge_call(call.call_id, device_id, call.device_list[0])
 
     def listen(self, call: CallInfo, device: DeviceInfo, next_command: NextCommand, event):

+ 1 - 1
src/core/callcenter/esl/handler/channel_bridge_handler.py

@@ -19,7 +19,7 @@ class ChannelBridgeHandler(EslEventHandler):
         device_id = EslEventUtil.getDeviceId(event)
         call = self.cache.get_call_info(call_id)
         device = call.device_info_map.get(device_id)
-        print('debugger::device_id is23232323232 ', device_id, device, flush=True)
+        self.logger.info('debugger::device_id is23232323232 ', device_id, device)
         if device.device_type == DeviceType.AGENT.code: # 如果是坐席接听 变更坐席状态
             self.dataHandleServer.update_agent_monitor_service_state(device_id, AgentServiceState.IDLE.code)
         pass

+ 11 - 11
src/core/callcenter/esl/handler/channel_hangup_handler.py

@@ -28,29 +28,29 @@ class ChannelHangupHandler(EslEventHandler):
         self.push_handler = PushHandler(inbound_client.logger)
 
     def handle(self, address, event, coreUUID):
-        print(json.loads(event.serialize('json')), flush=True)
+        self.logger.info(json.loads(event.serialize('json')))
         try:
             call_id = EslEventUtil.getCallId(event)
-            print('debugger::call_id is ', call_id, flush=True)
+            self.logger.info('debugger::call_id is ', call_id)
             if not call_id:
                 self.release(event)
-                print("call_id is null", flush=True)
+                self.logger.info("call_id is null")
                 return
             call = self.cache.get_call_info(call_id)
-            print('debugger::call_info is ', call, flush=True)
+            self.logger.info('debugger::call_info is ', call)
             if not call:
-                print("call:%s is null", call_id, flush=True)
+                self.logger.info("call:%s is null", call_id)
                 return
             device_id = EslEventUtil.getDeviceId(event)
             device_id = device_id if device_id else EslEventUtil.getUniqueId(event)
             device = call.device_info_map.get(device_id)
-            # print('debugger::device_id is ', device_id, flush=True)
+            # self.logger.info('debugger::device_id is ', device_id)
             if not device:
-                print("device:%s is null", device_id, flush=True)
+                self.logger.info("device:%s is null", device_id)
                 return
 
             count = len(call.device_list)
-            print('lwdebugger::ChannelHangupHandler, call_id=%s, device_id=%s, count=%s'% (call_id, device_id, count), flush=True)
+            self.logger.info('lwdebugger::ChannelHangupHandler, call_id=%s, device_id=%s, count=%s'% (call_id, device_id, count))
             try:
                 call.device_list.remove(device_id)
             except:
@@ -81,18 +81,18 @@ class ChannelHangupHandler(EslEventHandler):
             if device.record_start_time:
                 device.record_time = int(device.end_time) - int(device.record_start_time)
             call.device_info_map[device.device_id] = device
-            # print("ceshiyix shijian",device)
+            # self.logger.info("ceshiyix shijian",device)
             # 更新通话记录
             # self.dataHandleServer.update_record(call_id, {"time_end": datetime.fromtimestamp(int(device.end_time)),"times":device.talk_time})
 
-            print('debugger::ChannelHangupHandler, hangup_reason=%s, device_type=%s' % (hangup_reason, device.device_type), flush=True)
+            self.logger.info('debugger::ChannelHangupHandler, hangup_reason=%s, device_type=%s' % (hangup_reason, device.device_type))
             # 如果是转人工
             # if 'transferToAgent' == hangup_reason and DeviceType.ROBOT.code == device.device_type:
             #     call.answer_flag = AnswerFlag.TRANSFER_TO_AGENT.code
             #     service_id = EslEventUtil.getLIBRAServiceId(event)
             #     call.transfer_agent = True
             #     self.cache.add_call_info(call)
-            #     print('debugger::ChannelHangupHandler, transferToAgent, service_id=%s' % (service_id), flush=True)
+            #     self.logger.info('debugger::ChannelHangupHandler, transferToAgent, service_id=%s' % (service_id))
             #     self.acd_service.transfer_to_agent(call, device_id, service_id)
             #     return
 

+ 7 - 7
src/core/callcenter/esl/handler/channel_park_handler.py

@@ -19,7 +19,7 @@ class ChannelParkHandler(EslEventHandler):
         super().__init__(inbound_client, bot_agent)
 
     def handle(self, address, event, coreUUID):
-        print("ChannelParkHandler, event=%s", json.loads(event.serialize('json')), flush=True)
+        self.logger.info("ChannelParkHandler, event=%s", json.loads(event.serialize('json')))
         service = event.getHeader("variable_service")
         if service:
             self.process_fxo_calling(event)
@@ -28,24 +28,24 @@ class ChannelParkHandler(EslEventHandler):
         call_id = getCallId(event)
         device_id = getUniqueId(event)
         need_hold_music = getVariableNeedHoldMusic(event)
-        print("park播放等待音标识 callId: %s deviceId: %s needHoldMusic:%s"%(call_id,device_id,need_hold_music), flush=True)
+        self.logger.info("park播放等待音标识 callId: %s deviceId: %s needHoldMusic:%s"%(call_id,device_id,need_hold_music))
         if need_hold_music:
             call_id = call_id if call_id else need_hold_music
             self.play_hold_music(call_id, device_id, event)
             return
 
     def play_hold_music(self, call_id, device_id, event):
-        print('debugger, ChannelParkHandler, call_id=%s, device_id=%s'%(call_id, device_id), flush=True)
+        self.logger.info('debugger, ChannelParkHandler, call_id=%s, device_id=%s'%(call_id, device_id))
         if not call_id or not device_id:
             return
         call_info = self.cache.get_call_info(call_id)
         if not call_info:
-            print("CHANNEL_PARK callInfo is null", flush=True)
+            self.logger.info("CHANNEL_PARK callInfo is null")
             return
 
         device_info = call_info.device_info_map.get(device_id)
         hold = self.cache.get_need_play_hold_music(call_id)
-        print('debugger, ChannelParkHandler, hold=%s, device_info=%s' % (hold, device_info), flush=True)
+        self.logger.info('debugger, ChannelParkHandler, hold=%s, device_info=%s' % (hold, device_info))
         if hold and "false" != hold and device_info.device_type == DeviceType.CUSTOMER.code:
             self.inbound_client.hold_play(device_id, HOLD_MUSIC_PATH)
             self.cache.del_need_play_hold_music(call_id)
@@ -58,7 +58,7 @@ class ChannelParkHandler(EslEventHandler):
         # 获取通话的 UUID
         device_id = event.getHeader("Unique-ID")
         service = event.getHeader("variable_service")
-        print(f"Incoming call with UUID: {device_id}  {service} is transfer to {destination}")
+        self.logger.info(f"Incoming call with UUID: {device_id}  {service} is transfer to {destination}")
         #self.inbound_client.con.execute("transfer", f"{destination} XML pbx.fuxicarbon.com", device_id)
         # self.con.execute("answer", "", call_uuid)
         self.cache.add_device_user_part(device_id, destination)
@@ -72,4 +72,4 @@ class ChannelParkHandler(EslEventHandler):
         # msg.addHeader("execute-app-arg", destination)
         # # 发送消息以执行 bridge 操作
         # self.con.sendEvent(msg)
-        # print(f"Call {call_uuid} is bridged to {destination}")
+        # self.logger.info(f"Call {call_uuid} is bridged to {destination}")