[SEBA-853] Collection BBR Logs
Change-Id: I25ae10408cc64db2591a8431e82f065e72ef55af
diff --git a/cmd/bbr/bbr.go b/cmd/bbr/bbr.go
index 30c3c71..a98decd 100644
--- a/cmd/bbr/bbr.go
+++ b/cmd/bbr/bbr.go
@@ -37,6 +37,15 @@
common.SetLogLevel(log.StandardLogger(), options.LogLevel, options.LogCaller)
+ if options.LogFile != "" {
+ file, err := os.OpenFile(options.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
+ if err == nil {
+ log.StandardLogger().Out = file
+ } else {
+ log.Fatal("Failed to log to file, using default stderr")
+ }
+ }
+
if *options.ProfileCpu != "" {
// start profiling
log.Infof("Creating profile file at: %s", *options.ProfileCpu)
diff --git a/internal/common/options.go b/internal/common/options.go
index 46c8752..41c3522 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -35,6 +35,7 @@
BBSimIp string
BBSimPort string
BBSimApiPort string
+ LogFile string
}
func GetBBSimOpts() *BBSimCliOptions {
@@ -74,6 +75,7 @@
bbsimIp := flag.String("bbsimIp", "127.0.0.1", "BBSim IP")
bbsimPort := flag.String("bbsimPort", "50060", "BBSim Port")
bbsimApiPort := flag.String("bbsimApiPort", "50070", "BBSim API Port")
+ logFile := flag.String("logfile", "", "Log to a file")
options := GetBBSimOpts()
@@ -82,6 +84,7 @@
*bbsimIp,
*bbsimPort,
*bbsimApiPort,
+ *logFile,
}
return bbrOptions
diff --git a/tests/bbr.groovy b/tests/bbr.groovy
index 19e90d3..dd558f2 100644
--- a/tests/bbr.groovy
+++ b/tests/bbr.groovy
@@ -44,7 +44,7 @@
docker rm -f bbsim || true
DOCKER_REPOSITORY=voltha/ DOCKER_TAG=candidate DOCKER_RUN_ARGS="-pon 4 -onu 16" make docker-run
sleep 5
- ./bbr -pon 4 -onu 16
+ ./bbr -pon 4 -onu 16 -logfile bbr_16_4.logs
docker logs bbsim 2>&1 | tee bbsim_16_4.logs
"""
}
@@ -57,7 +57,7 @@
docker rm -f bbsim || true
DOCKER_REPOSITORY=voltha/ DOCKER_TAG=candidate DOCKER_RUN_ARGS="-pon 4 -onu 32" make docker-run
sleep 5
- ./bbr -pon 4 -onu 32
+ ./bbr -pon 4 -onu 32 -logfile bbr_32_4.logs
docker logs bbsim 2>&1 | tee bbsim_32_4.logs
"""
}
@@ -70,7 +70,7 @@
docker rm -f bbsim || true
DOCKER_REPOSITORY=voltha/ DOCKER_TAG=candidate DOCKER_RUN_ARGS="-pon 8 -onu 32" make docker-run
sleep 5
- ./bbr -pon 8 -onu 32
+ ./bbr -pon 8 -onu 32 -logfile bbr_32_8.logs
docker logs bbsim 2>&1 | tee bbsim_32_8.logs
"""
}