lib/chambermaid/base.rb in chambermaid-0.3.2 vs lib/chambermaid/base.rb in chambermaid-0.4.0
- old
+ new
@@ -1,5 +1,7 @@
+require "logger"
+
require "chambermaid/environment"
require "chambermaid/namespace"
require "chambermaid/parameter_store"
module Chambermaid
@@ -11,11 +13,10 @@
extend self
def configure
yield self
- load!
end
# @todo
def configuration
raise "Namespaces must be defined" unless @namespaces
@@ -100,9 +101,42 @@
#
# @see {Chambermaid::Base.add_namespace}
def add_service(service, overload: false)
service = "/#{service}" unless service[0] == "/"
add_namespace(service)
+ end
+
+ # !@attribute [r] logger
+ # @return [Logger]
+ def logger
+ @logger ||= Logger.new(STDOUT,
+ level: log_level,
+ progname: "Chambermaid"
+ )
+ end
+
+ # !@attribute [w] logger
+ # @return [Logger]
+ def logger=(val)
+ @logger = val
+ @logger.progname = "Chambermaid"
+ logger
+ end
+
+ # !@attribute [r] log_level
+ # @return [Symbol] (default = :info) current logger level
+ def log_level
+ return logger.level unless @logger.nil?
+ return @log_level unless @log_level.nil?
+ return :info
+ end
+
+ # !@attribute [w] log_level
+ # @return [Symbol] (default = :info) current logger level
+ def log_level=(val = :info)
+ @logger.level = val unless @logger.nil?
+ @log_level = val
+ val
end
private
def namespaces