Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 1 | # Copyright 2015 gRPC authors. |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 2 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 6 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 14 | |
Nick Gauthier | f233d96 | 2015-05-20 14:02:50 -0400 | [diff] [blame] | 15 | # GRPC contains the General RPC module. |
| 16 | module GRPC |
Tim Emiola | 25f5011 | 2015-08-17 12:22:23 -0700 | [diff] [blame] | 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 | |
Tim Emiola | 27ccd19 | 2015-08-18 16:15:14 -0700 | [diff] [blame] | 42 | # Inject the noop #logger if no module-level logger method has been injected. |
| 43 | extend DefaultLogger unless methods.include?(:logger) |
Nick Gauthier | f233d96 | 2015-05-20 14:02:50 -0400 | [diff] [blame] | 44 | end |