3737from apps .utils import APIModel
3838from apps .utils .basic import filter_values , to_int_or_default
3939from apps .utils .local import get_request_username , get_tenant_id
40- from apps .utils .time_tools import local_dt_str2utc_dt
40+ from apps .utils .time_tools import format_log_time , local_dt_str2utc_dt
4141from common .api import NodeApi
4242from common .api .exception import DataAPIException
4343
@@ -910,7 +910,7 @@ def retrieve(self, params: Dict[str, Any], user_timezone):
910910 return job_detail
911911
912912 @staticmethod
913- def get_log_base (subscription_id : int , task_id_list : List [int ], instance_id : str ) -> list :
913+ def get_log_base (subscription_id : int , task_id_list : List [int ], instance_id : str , user_timezone ) -> list :
914914 """
915915 根据订阅任务ID,实例ID,获取日志
916916 :param subscription_id: 订阅任务ID
@@ -928,21 +928,21 @@ def get_log_base(subscription_id: int, task_id_list: List[int], instance_id: str
928928 {
929929 "step" : step ["node_name" ],
930930 "status" : step ["status" ],
931- "log" : step ["log" ],
932- "start_time" : step .get ("start_time" ),
933- "finish_time" : step .get ("finish_time" ),
931+ "log" : format_log_time ( step ["log" ], target_timezone = user_timezone ) ,
932+ "start_time" : format_log_time ( step .get ("start_time" ), target_timezone = user_timezone ),
933+ "finish_time" : format_log_time ( step .get ("finish_time" ), target_timezone = user_timezone ),
934934 }
935935 )
936936 return logs
937937
938- def get_log (self , instance_id : str ) -> list :
938+ def get_log (self , instance_id : str , user_timezone ) -> list :
939939 """
940940 获得日志
941941 :param instance_id: 实例ID
942942 :return: 日志列表
943943 """
944944 # 获得并返回日志
945- return JobHandler .get_log_base (self .data .subscription_id , self .data .task_id_list , instance_id )
945+ return JobHandler .get_log_base (self .data .subscription_id , self .data .task_id_list , instance_id , user_timezone )
946946
947947 def collect_log (self , instance_id : int ) -> list :
948948 return NodeApi .collect_subscription_task_detail ({"job_id" : self .job_id , "instance_id" : instance_id })
0 commit comments