diff options
Diffstat (limited to 'src/ruby/lib/grpc/logconfig.rb')
-rw-r--r-- | src/ruby/lib/grpc/logconfig.rb | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/ruby/lib/grpc/logconfig.rb b/src/ruby/lib/grpc/logconfig.rb index e9b4aa3c95..2bb7c86d5e 100644 --- a/src/ruby/lib/grpc/logconfig.rb +++ b/src/ruby/lib/grpc/logconfig.rb @@ -27,17 +27,32 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'logging' - # GRPC contains the General RPC module. module GRPC - extend Logging.globally -end + # DefaultLogger is a module included in GRPC if no other logging is set up for + # it. See ../spec/spec_helpers an example of where other logging is added. + module DefaultLogger + def logger + LOGGER + end + + private + + # NoopLogger implements the methods of Ruby's conventional logging interface + # that are actually used internally within gRPC with a noop implementation. + class NoopLogger + def info(_ignored) + end -Logging.logger.root.appenders = Logging.appenders.stdout -Logging.logger.root.level = :info + def debug(_ignored) + end -# TODO: provide command-line configuration for logging -Logging.logger['GRPC'].level = :info -Logging.logger['GRPC::ActiveCall'].level = :info -Logging.logger['GRPC::BidiCall'].level = :info + def warn(_ignored) + end + end + + LOGGER = NoopLogger.new + end + + include DefaultLogger unless method_defined?(:logger) +end |