Skip to content

Commit d65fa65

Browse files
authored
Merge pull request apache#41 from wanhailong/master
Add time parser for 3tee service
2 parents 571fa8a + b681949 commit d65fa65

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

go/src/pili.qiniu.com/dsync.v1/parse.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
StrNgxErr = "NGXERR"
3030
StrNgxProxy = "NGXPROXY"
3131
StrOvs = "OVS"
32+
Str3TEE = "3TEE"
3233

3334
StrTx0 = "TX0"
3435
StrTx1 = "TX1"
@@ -62,6 +63,8 @@ func ParseTime(line []byte, typ string) (ts int64, err error) {
6263
t, err = parsePili(line)
6364
case StrOvs:
6465
t, err = parseOVS(line)
66+
case Str3TEE:
67+
t, err = parseTime3tee(line)
6568
default:
6669
panic(typ)
6770
}
@@ -90,6 +93,18 @@ func parseLocal(layout, dest string) (time.Time, error) {
9093
return t, err
9194
}
9295

96+
// (3tee)
97+
// 2014/04/16 14:54:01
98+
const TimeFmt3tee = "2006-01-02 15:04:05"
99+
100+
func parseTime3tee(line []byte) (t time.Time, err error) {
101+
if len(line) < len(TimeFmt3tee) {
102+
err = ErrLineTooShortToParseTime
103+
return
104+
}
105+
return parseLocal(TimeFmt3tee, string(line[0:len(TimeFmt3tee)]))
106+
}
107+
93108
// (app|ngx.err)
94109
// 2014/04/16 14:54:01
95110
const TimeFmtAppNgxErr = "2006/01/02 15:04:05"

go/src/pili.qiniu.com/dsync.v1/parse_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func TestParseTime(t *testing.T) {
107107
StrApp,
108108
1444432800000000000,
109109
},
110+
{
111+
`2015-10-10 07:20:00.09s [:0000001f DEBUG http req: /rtc/room/create]`,
112+
Str3TEE,
113+
1444432800000000000,
114+
},
110115
{
111116
`106.38.216.15 - - [10/Oct/2015:09:50:00 +0800] "GET /feedimage/21/14/21140F47-50DF-9F13-585B-42827E2F55F120151006_S.webp HTTP/1.1" 200 4095 3612 "-" "MomoChat/6.4 Android/436 (HUAWEI MT7-CL00; Android 4.4.2; Gapps 1; zh_CN; 11)" "111.40.196.86" 10.30.22.39:5000 momo-img.qiniucdn.com 7VYAAAZa_AMqsAsU 0.005 0.005 chinanetcenter`,
112117
StrNgxAcc,

0 commit comments

Comments
 (0)