Class: Loggr::SLF4J::Logger
- Inherits:
-
Object
- Object
- Loggr::SLF4J::Logger
- Includes:
- Loggr::Severity
- Defined in:
- lib/loggr/slf4j/logger.rb
Overview
A logger which is backed by SLF4J, thus only useable in a JRuby environment.
Constant Summary
Constants included from Loggr::Severity
Loggr::Severity::DEBUG, Loggr::Severity::ERROR, Loggr::Severity::FATAL, Loggr::Severity::INFO, Loggr::Severity::TRACE, Loggr::Severity::UNKNOWN, Loggr::Severity::WARN
Instance Attribute Summary collapse
-
#auto_flushing ⇒ Object
readonly
Just to ensure compatiability with AS::BufferedLogger.
-
#close ⇒ Object
readonly
Just to ensure compatiability with AS::BufferedLogger.
-
#flush ⇒ Object
readonly
Just to ensure compatiability with AS::BufferedLogger.
-
#java_logger ⇒ Object
readonly
Access raw SLF4J logger & marker instances.
-
#java_marker ⇒ Object
readonly
Access raw SLF4J logger & marker instances.
-
#level ⇒ Object
Basically has no impact, because is handled by SLF4J.
Class Method Summary collapse
-
.in_java_notation(name) ⇒ Object
If a class, module or object is used converts ‘Foo::Bar::SomeThing` to java notation: `foo.bar.SomeThing`.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Logger
constructor
Create a new Logger instance for the given name.
Constructor Details
#initialize(name, options = {}) ⇒ Logger
Create a new Logger instance for the given name
37 38 39 40 41 42 43 44 45 |
# File 'lib/loggr/slf4j/logger.rb', line 37 def initialize(name, = {}) name = self.class.in_java_notation(name) @java_logger = Java::OrgSlf4j::LoggerFactory.getLogger(name.to_s) @java_marker = MarkerFactory[[:marker]] # seriously, this is handled by slf4j and pretty dynamic @level = Logger::UNKNOWN @auto_flushing = true end |
Instance Attribute Details
#auto_flushing ⇒ Object (readonly)
Just to ensure compatiability with AS::BufferedLogger
30 31 32 |
# File 'lib/loggr/slf4j/logger.rb', line 30 def auto_flushing @auto_flushing end |
#close ⇒ Object (readonly)
Just to ensure compatiability with AS::BufferedLogger
30 31 32 |
# File 'lib/loggr/slf4j/logger.rb', line 30 def close @close end |
#flush ⇒ Object (readonly)
Just to ensure compatiability with AS::BufferedLogger
30 31 32 |
# File 'lib/loggr/slf4j/logger.rb', line 30 def flush @flush end |
#java_logger ⇒ Object (readonly)
Access raw SLF4J logger & marker instances
33 34 35 |
# File 'lib/loggr/slf4j/logger.rb', line 33 def java_logger @java_logger end |
#java_marker ⇒ Object (readonly)
Access raw SLF4J logger & marker instances
33 34 35 |
# File 'lib/loggr/slf4j/logger.rb', line 33 def java_marker @java_marker end |
#level ⇒ Object
Basically has no impact, because is handled by SLF4J
27 28 29 |
# File 'lib/loggr/slf4j/logger.rb', line 27 def level @level end |
Class Method Details
.in_java_notation(name) ⇒ Object
If a class, module or object is used converts ‘Foo::Bar::SomeThing` to java notation: `foo.bar.SomeThing`. Symbols and Strings are left as is!
70 71 72 73 74 75 76 |
# File 'lib/loggr/slf4j/logger.rb', line 70 def self.in_java_notation(name) return name.to_s if name.respond_to?(:to_str) || name.is_a?(Symbol) name = name.is_a?(Module) ? name.name.to_s : name.class.name.to_s parts = name.split('::') last = parts.pop parts.map { |p| p.downcase }.push(last).join('.') end |