Skip to content

Commit

Permalink
Merge pull request #641 from iotaledger/fix/empty-logger
Browse files Browse the repository at this point in the history
Check if logger is nil in `ParentLogger` and `UnsubscribeFromParentLogger`
  • Loading branch information
muXxer authored Jan 26, 2024
2 parents ebf40dc + e3dcf7f commit 9caf791
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions log/logger_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (l *logger) NewChildLogger(name string, enumerateChildren ...bool) (childLo

// ParentLogger returns the parent logger of the logger (or nil if it is the root).
func (l *logger) ParentLogger() Logger {
if l.parentLogger == nil {
if l == nil || l.parentLogger == nil {
return nil
}

Expand All @@ -296,7 +296,7 @@ func (l *logger) ParentLogger() Logger {
// It is important to call this method whenever we remove all references to the logger, otherwise the logger will
// not be garbage collected.
func (l *logger) UnsubscribeFromParentLogger() {
if l.unsubscribeFromParent != nil {
if l != nil && l.unsubscribeFromParent != nil {
l.unsubscribeFromParent()
}
}
Expand Down

0 comments on commit 9caf791

Please sign in to comment.