Skip to content

Commit 8f3763f

Browse files
authored
PBM-1473 - Improve PBM behavior when the log.path option is modified in the configuration file (#1079)
* rename function * remove option to change path
1 parent 71ac548 commit 8f3763f

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

cmd/pbm-agent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func runAgent(
207207
defer logger.Close()
208208

209209
viper.OnConfigChange(func(e fsnotify.Event) {
210-
logger.SetOpts(buildLogOpts())
210+
logger.SetLogLevelAndJSON(buildLogOpts())
211211
newOpts := logger.Opts()
212212
logger.Printf("log options updated: log-path=%s, log-level:%s, log-json:%t",
213213
newOpts.LogPath, newOpts.LogLevel, newOpts.LogJSON)

pbm/log/discard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (discardLoggerImpl) Output(ctx context.Context, e *Entry) error {
5656

5757
func (discardLoggerImpl) Opts() *Opts { return nil }
5858

59-
func (discardLoggerImpl) SetOpts(cfg *Opts) {
59+
func (discardLoggerImpl) SetLogLevelAndJSON(cfg *Opts) {
6060
}
6161

6262
type discardEventImpl struct{}

pbm/log/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Logger interface {
3636
Fatal(event, obj, opid string, epoch primitive.Timestamp, msg string, args ...any)
3737
Output(ctx context.Context, e *Entry) error
3838
Opts() *Opts
39-
SetOpts(cfg *Opts)
39+
SetLogLevelAndJSON(cfg *Opts)
4040
}
4141

4242
type LogEvent interface {

pbm/log/logger.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,14 @@ func (l *loggerImpl) Opts() *Opts {
314314
}
315315
}
316316

317-
func (l *loggerImpl) SetOpts(cfg *Opts) {
317+
func (l *loggerImpl) SetLogLevelAndJSON(cfg *Opts) {
318318
if cfg == nil {
319319
return
320320
}
321321

322322
l.mu.Lock()
323323
defer l.mu.Unlock()
324324

325-
if cfg.LogPath != "" && l.logger.logPath != cfg.LogPath {
326-
l.createLogger(cfg.LogPath)
327-
}
328325
if cfg.LogLevel != "" && l.logLevel.String() != cfg.LogLevel {
329326
l.logLevel = strToSeverity(cfg.LogLevel)
330327
}

0 commit comments

Comments
 (0)