diff options
author | Ryan Cragun <me@ryan.ec> | 2017-04-18 16:46:16 -0700 |
---|---|---|
committer | Ryan Cragun <me@ryan.ec> | 2017-04-19 13:26:37 -0700 |
commit | 88ff22da3888462e23be414de46ec1a7426e69b8 (patch) | |
tree | 0b853d7616ee871deae12fc4d7db9cf967012a01 /lib/mixlib/authentication/null_logger.rb | |
parent | 0c5c683a23b7d4b6fd2cbb61a2010af2e513aacf (diff) | |
download | mixlib-authentication-ryan/cloud-319.tar.gz |
[CLOUD-319] Make mixlib-log an optional dependencyryan/cloud-319
This change makes mixlib-log an optional dependency. When it's available
in the LOAD_PATH it will be used by default, otherwise, all logging will
will be forwarded to a null logger that does nothing. This is useful for
cases where small utilities can consume mixlib-authentication and not
have to pull in additional gems.
Signed-off-by: Ryan Cragun <me@ryan.ec>
Diffstat (limited to 'lib/mixlib/authentication/null_logger.rb')
-rw-r--r-- | lib/mixlib/authentication/null_logger.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mixlib/authentication/null_logger.rb b/lib/mixlib/authentication/null_logger.rb new file mode 100644 index 0000000..2bc9e31 --- /dev/null +++ b/lib/mixlib/authentication/null_logger.rb @@ -0,0 +1,24 @@ +module Mixlib + module Authentication + module NullLogger + + attr_accessor :level + + %i{debug info warn error fatal}.each do |method_name| + class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) + def #{method_name}(msg=nil, &block) + true + end + METHOD_DEFN + end + + %i{debug? info? warn? error? fatal?}.each do |method_name| + class_eval(<<-METHOD_DEFN, __FILE__, __LINE__) + def #{method_name} + false + end + METHOD_DEFN + end + end + end +end |