Skip to content

Commit b5500fa

Browse files
authored
Merge pull request #1188 from shangmin-001/shangmin01
[PDR-14800][feat]logkit-pro支持.gzip格式文件采集
2 parents 8be7ed8 + 50e5f84 commit b5500fa

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

reader/extract/reader.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func NewReader(meta *reader.Meta, path string, opt Opts) (*Reader, error) {
5757
return nil, err
5858
}
5959
tp = "tar"
60-
} else if strings.HasSuffix(path, ".gz") {
60+
} else if strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".gzip") {
6161
rd, err = NewGZ(path, opt)
6262
if err != nil {
63-
log.Errorf("New .gz err %v", err)
63+
log.Errorf("New .gz or .gzip err %v", err)
6464
return nil, err
6565
}
6666
tp = "gz"
@@ -303,8 +303,8 @@ type GZ struct {
303303
}
304304

305305
func NewGZ(path string, opt Opts) (*GZ, error) {
306-
if !strings.HasSuffix(path, ".gz") {
307-
return nil, fmt.Errorf("%s is not .gz format", path)
306+
if !(strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".gzip")) {
307+
return nil, fmt.Errorf("%s is not .gz or .gzip format", path)
308308
}
309309
f, err := os.Open(path)
310310
if err != nil {

reader/read.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package reader

reader/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func getTags(tagFile string) (tags map[string]interface{}, err error) {
144144
}
145145

146146
func CompressedFile(path string) bool {
147-
if strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".tar") || strings.HasSuffix(path, ".zip") {
147+
if strings.HasSuffix(path, ".gzip") || strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".tar") || strings.HasSuffix(path, ".zip") {
148148
return true
149149
}
150150
return false

sender/sender.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
. "github.com/qiniu/logkit/utils/models"
1010
)
1111

12+
1213
// Sender send data to pandora, prometheus such different destinations
1314
type Sender interface {
1415
Name() string

0 commit comments

Comments
 (0)