From eaf1d1be6d9e39b68125639106cfc31c052d1ed3 Mon Sep 17 00:00:00 2001 From: yanli <38203792+tianyanli@users.noreply.github.com> Date: Mon, 1 Jun 2020 09:53:36 +0800 Subject: [PATCH] Add log time format 02 / 01 / 2006:15:04:05 (#164) * Add log time format 02 / 01 / 2006:15:04:05 * Server Add log time format 02 / 01 / 2006:15:04:05 --- src/modules/collector/stra/log.go | 3 +++ src/modules/monapi/http/routes/collect.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/modules/collector/stra/log.go b/src/modules/collector/stra/log.go index 80ec4e98..0ef6d130 100644 --- a/src/modules/collector/stra/log.go +++ b/src/modules/collector/stra/log.go @@ -265,6 +265,9 @@ func GetPatAndTimeFormat(tf string) (string, string) { case "mmdd HH:MM:SS": pat = `(0[1-9]|1[012])([012][0-9]|3[01])\s([01][0-9]|2[0-4])(:[012345][0-9]){2}` timeFormat = "0102 15:04:05" + case "dd/mm/yyyy:HH:MM:SS": + pat = `([012][0-9]|3[01])/(0[1-9]|1[012])/(2[0-9]{3}):([01][0-9]|2[0-4])(:[012345][0-9]){2}` + timeFormat = "02/01/2006:15:04:05" default: logger.Errorf("match time pac failed : [timeFormat:%s]", tf) return "", "" diff --git a/src/modules/monapi/http/routes/collect.go b/src/modules/monapi/http/routes/collect.go index 2cba9529..7388920c 100644 --- a/src/modules/monapi/http/routes/collect.go +++ b/src/modules/monapi/http/routes/collect.go @@ -508,6 +508,9 @@ func GetPatAndTimeFormat(tf string) (string, string) { case "mmdd HH:MM:SS": pat = `(0[1-9]|1[012])([012][0-9]|3[01])\s([01][0-9]|2[0-4])(:[012345][0-9]){2}` timeFormat = "0102 15:04:05" + case "dd/mm/yyyy:HH:MM:SS": + pat = `([012][0-9]|3[01])/(0[1-9]|1[012])/(2[0-9]{3}):([01][0-9]|2[0-4])(:[012345][0-9]){2}` + timeFormat = "02/01/2006:15:04:05" default: logger.Errorf("match time pac failed : [timeFormat:%s]", tf) return "", ""