blob: 4f135586272b5d1b32cafc2eb3920101f7278ed0 [file] [log] [blame]
Jan Tattermusch7897ae92017-06-07 22:57:36 +02001# Copyright 2015 gRPC authors.
nnoble097ef9b2014-12-01 17:06:10 -08002#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# 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
nnoble097ef9b2014-12-01 17:06:10 -08006#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02007# http://www.apache.org/licenses/LICENSE-2.0
nnoble097ef9b2014-12-01 17:06:10 -08008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# 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.
nnoble097ef9b2014-12-01 17:06:10 -080014
Nick Gauthierf233d962015-05-20 14:02:50 -040015# GRPC contains the General RPC module.
16module GRPC
Tim Emiola25f50112015-08-17 12:22:23 -070017 # 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
Tim Emiola27ccd192015-08-18 16:15:14 -070042 # Inject the noop #logger if no module-level logger method has been injected.
43 extend DefaultLogger unless methods.include?(:logger)
Nick Gauthierf233d962015-05-20 14:02:50 -040044end