1 # Copyright 2015 gRPC authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # GRPC contains the General RPC module. 16 module GRPC 17 # DefaultLogger is a module included in GRPC if no other logging is set up for 18 # it. See ../spec/spec_helpers an example of where other logging is added. 19 module DefaultLogger 20 def logger 21 LOGGER 22 end 23 24 private 25 26 # NoopLogger implements the methods of Ruby's conventional logging interface 27 # that are actually used internally within gRPC with a noop implementation. 28 class NoopLogger 29 def info(_ignored) 30 end 31 32 def debug(_ignored) 33 end 34 35 def warn(_ignored) 36 end 37 end 38 39 LOGGER = NoopLogger.new 40 end 41 42 # Inject the noop #logger if no module-level logger method has been injected. 43 extend DefaultLogger unless methods.include?(:logger) 44 end 45