Skip to content

Commit

Permalink
fix:修复日志中文乱码问题
Browse files Browse the repository at this point in the history
pref:优化日志打印
  • Loading branch information
jsonwan committed Jun 23, 2021
1 parent 06f3670 commit 271d30a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/main/kotlin/com/tencent/bk/devops/atom/task/InnerJobAtom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ class InnerJobAtom : TaskAtom<InnerJobParam> {
return dynamicGroupIdList
}

private fun printLink(bizId: String, taskInstanceId: Long, jobHost: String) {
logger.info("对接蓝鲸企业版3.x/社区版6.x中的作业平台请点击以下链接查看详情:")
logger.info(JobUtils.getV3DetailUrl(bizId, taskInstanceId, jobHost))
logger.info("对接蓝鲸企业版2.x/社区版5.x中的作业平台请点击以下链接查看详情:")
logger.info(JobUtils.getV2DetailUrl(bizId, taskInstanceId, jobHost))
}

fun distribute(
param: InnerJobParam,
fileSource: FastPushFileSource,
Expand Down Expand Up @@ -249,7 +256,7 @@ class InnerJobAtom : TaskAtom<InnerJobParam> {
)
try {
val taskInstanceId = JobUtils.fastPushFileV2(fastPushFileReq, this.esbHost)
logger.info(JobUtils.getDetailUrl(jobHost, bizId, taskInstanceId))
printLink(bizId,taskInstanceId,jobHost)
val startTime = System.currentTimeMillis()

checkStatus(
Expand All @@ -264,7 +271,7 @@ class InnerJobAtom : TaskAtom<InnerJobParam> {
result = result
)

logger.info(JobUtils.getDetailUrl(jobHost, bizId, taskInstanceId))
printLink(bizId,taskInstanceId,jobHost)
} catch (e: Exception) {
logger.error("Job API invoke failed", e)
result.status = Status.failure
Expand Down Expand Up @@ -301,7 +308,7 @@ class InnerJobAtom : TaskAtom<InnerJobParam> {

while (needContinue) {
Thread.sleep(5000)
logger.info(JobUtils.getDetailUrl(jobHost, bizId, taskInstanceId))
printLink(bizId,taskInstanceId,jobHost)
val taskResult = JobUtils.getTaskResult(appId, appSecret, bizId, taskInstanceId, operator, esbHost)
if (taskResult.isFinish) {
needContinue = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ object JobUtils {
return jobResourceApi.getTaskResult(appId, appSecret, bizId, taskInstanceId, operator, jobHost)
}

fun getDetailUrl(jobHost: String, appId: String, taskInstanceId: Long): String {
return "<a target='_blank' href='$jobHost/?taskInstanceList&appId=$appId#taskInstanceId=$taskInstanceId'>到作业平台V2查看详情(Go to JobV2 for Detail, click this if using BlueKing5.x)</a> <a target='_blank' href='$jobHost/api_execute/$taskInstanceId'>到作业平台V3查看详情(Go to JobV3 for Detail, click this if using BlueKing6.x)</a>"
fun getV2DetailUrl(appId: String, taskInstanceId: Long, jobHost: String): String {
return "JobV2: <a target='_blank' href='$jobHost/?taskInstanceList&appId=$appId#taskInstanceId=$taskInstanceId'>到作业平台V2查看详情(Go to JobV2 for Detail, click this if using BlueKing5.x)</a>";
}

fun getV3DetailUrl(appId: String, taskInstanceId: Long, jobHost: String): String {
return "JobV3: <a target='_blank' href='$jobHost/api_execute/$taskInstanceId'>到作业平台V3查看详情(Go to JobV3 for Detail, click this if using BlueKing6.x)</a>"
}
}

0 comments on commit 271d30a

Please sign in to comment.