Class: OpenTelemetry::Internal::ProxyLoggerProvider Private
- Inherits:
-
Logs::LoggerProvider
- Object
- Logs::LoggerProvider
- OpenTelemetry::Internal::ProxyLoggerProvider
- Defined in:
- lib/opentelemetry/internal/proxy_logger_provider.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
ProxyLoggerProvider is an implementation of Logs::LoggerProvider. It is the default global logger provider returned by OpenTelemetry.logger_provider. It delegates to a “real” LoggerProvider after the global logger provider is registered. It returns ProxyLogger instances until the delegate is installed.
Instance Method Summary collapse
-
#delegate=(provider) ⇒ Object
private
Set the delegate logger provider.
-
#initialize ⇒ ProxyLoggerProvider
constructor
private
Returns a new ProxyLoggerProvider instance.
-
#logger(name = nil, version = nil) ⇒ Logger
private
Returns a Logger instance.
Constructor Details
#initialize ⇒ ProxyLoggerProvider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new OpenTelemetry::Internal::ProxyLoggerProvider instance.
21 22 23 24 25 26 27 |
# File 'lib/opentelemetry/internal/proxy_logger_provider.rb', line 21 def initialize super @mutex = Mutex.new @registry = {} @delegate = nil end |
Instance Method Details
#delegate=(provider) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the delegate logger provider. If this is called more than once, a warning will be logged and superfluous calls will be ignored.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/opentelemetry/internal/proxy_logger_provider.rb', line 33 def delegate=(provider) unless @delegate.nil? OpenTelemetry.logger.warn 'Attempt to reset delegate in ProxyLoggerProvider ignored.' return end @mutex.synchronize do @delegate = provider @registry.each { |key, logger| logger.delegate = provider.logger(key.name, key.version) } end end |
#logger(name = nil, version = nil) ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a Logger instance.
51 52 53 54 55 56 57 |
# File 'lib/opentelemetry/internal/proxy_logger_provider.rb', line 51 def logger(name = nil, version = nil) @mutex.synchronize do return @delegate.logger(name, version) unless @delegate.nil? @registry[Key.new(name, version)] ||= ProxyLogger.new end end |