Skip to content

Commit 3a81368

Browse files
committed
resolve possible collision for answlog filepath among several pools
commit_hash:8bcdbc50a0c1f8630d5357454a737fb74606b3a3
1 parent 61502c1 commit 3a81368

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

components/guns/grpc/core.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func DefaultGunConfig() GunConfig {
7777
Target: "default target",
7878
AnswLog: answlog.Config{
7979
Enabled: false,
80-
Path: "answ.log",
8180
Filter: filter.FilterAll,
8281
Sampling: answlog.Sampling{
8382
Enabled: true,

components/guns/grpc/scenario/core.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func DefaultGunConfig() GunConfig {
4242
Target: "default target",
4343
AnswLog: answlog.Config{
4444
Enabled: false,
45-
Path: "answ.log",
4645
Filter: filter.FilterAll,
4746
Sampling: answlog.Sampling{
4847
Enabled: true,

components/guns/http/connect.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func DefaultConnectGunConfig() GunConfig {
5151
},
5252
AnswLog: answlog.Config{
5353
Enabled: false,
54-
Path: "answ.log",
5554
Filter: filter.FilterAll,
5655
Sampling: answlog.Sampling{
5756
Enabled: true,

components/guns/http/http.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func DefaultHTTPGunConfig() GunConfig {
9393
},
9494
AnswLog: answlog.Config{
9595
Enabled: false,
96-
Path: "answ.log",
9796
Filter: filter.FilterAll,
9897
Sampling: answlog.Sampling{
9998
Enabled: true,

lib/answlog/logger.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ func Init(path string, enabled bool, opts ...LoggerOpt) *Logger {
9797
}
9898

9999
func getAnswWriter(path string) zapcore.WriteSyncer {
100-
if path == "" {
101-
path = "./answ.log"
100+
var file *os.File
101+
if path != "" {
102+
file, _ = os.Create(path)
103+
} else {
104+
pattern := "answ_" + "*" + ".log"
105+
file, _ = os.CreateTemp(".", pattern)
102106
}
103-
file, _ := os.Create(path)
107+
104108
return zapcore.AddSync(file)
105109
}

0 commit comments

Comments
 (0)