Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

keep protected under protected

  • Loading branch information...
commit 1acde29439731c499532074848cc895e8ac6e9c5 1 parent cbd0e87
@mkristian authored
Showing with 45 additions and 42 deletions.
  1. +21 −20 lib/slf4r/logging_logger.rb
  2. +24 −22 lib/slf4r/ruby_logger.rb
View
41 lib/slf4r/logging_logger.rb
@@ -3,9 +3,9 @@
module Slf4r
class LoggerFacade < AbstractLoggerFacade
-
+
attr_reader :logger
-
+
def initialize(name)
super
log_name = nil
@@ -25,39 +25,40 @@ def log(type, msg)
@logger.add(type, msg)
end
- public
-
- def debug?
- @logger.level == 0
- end
+ protected
def _debug(msg)
log(0, msg)
end
- def info?
- @logger.level <= 1
- end
-
def _info(msg)
log(1, msg)
end
- def warn?
- @logger.level <= 2
- end
-
def _warn(msg)
log(2, msg)
end
- def error?
- @logger.level <= 3
- end
-
def _error(msg)
log(3, msg)
end
-
+
+ public
+
+ def debug?
+ @logger.level == 0
+ end
+
+ def info?
+ @logger.level <= 1
+ end
+
+ def warn?
+ @logger.level <= 2
+ end
+
+ def error?
+ @logger.level <= 3
+ end
end
end
View
46 lib/slf4r/ruby_logger.rb
@@ -1,9 +1,9 @@
-require 'logger.rb'
+require 'logger'
require 'slf4r/abstract_logger_facade'
module Slf4r
class LoggerFacade4RubyLogger
-
+
@@file = STDERR
@@datetime_format = "%Y-%m-%d %H:%M:%S "
@@ -17,7 +17,7 @@ def self.new_logger_facade(name)
end
def self.level=(level)
- @@level = level.instance_of?(Fixnum) ? level :
+ @@level = level.instance_of?(Fixnum) ? level :
::Logger.const_get(level.to_s.upcase)
end
@@ -29,9 +29,9 @@ def self.file=(file)
@@file = file
end
end
-
+
class LoggerFacade < AbstractLoggerFacade
-
+
def initialize(name)
super
@logger = LoggerFacade4RubyLogger.new_logger_facade(name)
@@ -43,38 +43,40 @@ def log(type, msg)
@logger.add(type, msg, @name)
end
- public
-
- def debug?
- @logger.debug?
- end
+ protected
def _debug(msg)
log(::Logger::DEBUG, msg)
end
- def info?
- @logger.info?
- end
-
def _info(msg)
log(::Logger::INFO, msg)
end
- def warn?
- @logger.warn?
- end
-
def _warn(msg)
log(::Logger::WARN, msg)
end
- def error?
- @logger.error?
- end
-
def _error(msg)
log(::Logger::ERROR, msg)
end
+
+ public
+
+ def debug?
+ @logger.debug?
+ end
+
+ def info?
+ @logger.info?
+ end
+
+ def warn?
+ @logger.warn?
+ end
+
+ def error?
+ @logger.error?
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.