Skip to content

Commit b80407e

Browse files
authored
Merge pull request reidmorrison#282 from eagletmt/recursive-lock
Allow SyncProcessor to be called from appenders
2 parents a448672 + ab95964 commit b80407e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
## [unreleased]
77

88
- Add support for Ruby 3.3
9+
- Allow SyncProcessor to be called from appenders
910
- Fix incorrect metrics usage examples in documentation
1011

1112
## [4.15.0]

lib/semantic_logger/sync_processor.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ module SemanticLogger
22
# The SyncProcessor performs logging in the current thread.
33
#
44
# Appenders are designed to only be used by one thread at a time, so all calls
5-
# are mutex protected in case SyncProcessor is being used in a multi-threaded environment.
5+
# are monitor protected in case SyncProcessor is being used in a multi-threaded environment.
66
class SyncProcessor
77
def add(*args, &block)
8-
@mutex.synchronize { @appenders.add(*args, &block) }
8+
@monitor.synchronize { @appenders.add(*args, &block) }
99
end
1010

1111
def log(*args, &block)
12-
@mutex.synchronize { @appenders.log(*args, &block) }
12+
@monitor.synchronize { @appenders.log(*args, &block) }
1313
end
1414

1515
def flush
16-
@mutex.synchronize { @appenders.flush }
16+
@monitor.synchronize { @appenders.flush }
1717
end
1818

1919
def close
20-
@mutex.synchronize { @appenders.close }
20+
@monitor.synchronize { @appenders.close }
2121
end
2222

2323
def reopen(*args)
24-
@mutex.synchronize { @appenders.reopen(*args) }
24+
@monitor.synchronize { @appenders.reopen(*args) }
2525
end
2626

2727
# Allow the internal logger to be overridden from its default of $stderr
@@ -47,7 +47,7 @@ def self.logger
4747
attr_reader :appenders
4848

4949
def initialize(appenders = nil)
50-
@mutex = Mutex.new
50+
@monitor = Monitor.new
5151
@appenders = appenders || Appenders.new(self.class.logger.dup)
5252
end
5353

0 commit comments

Comments
 (0)