Class: OpenHAB::Logger
- Inherits:
-
Object
- Object
- OpenHAB::Logger
- Defined in:
- lib/openhab/log.rb
Overview
Ruby Logger that forwards messages at appropriate levels to openHAB Logger
Constant Summary collapse
- PREFIX =
The base prefix for all loggers from this gem.
"org.openhab.automation.jrubyscripting"
- LEVELS =
Returns Supported logging levels.
%i[trace debug warn info error].freeze
Instance Attribute Summary collapse
-
#level ⇒ :error, ...
The current log level.
Class Method Summary collapse
-
.events ⇒ Logger
The events logger (events.log).
-
.gem_root ⇒ Logger
The root logger for this gem.
-
.root ⇒ Logger
The root logger (all of openHAB).
Instance Method Summary collapse
-
#debug(msg = nil) { ... } ⇒ void
Log a message at debug level.
-
#debug? ⇒ true, false
If the logger is enabled at debug level.
-
#error(msg = nil) { ... } ⇒ void
Log a message at error level.
-
#error? ⇒ true, false
If the logger is enabled at error level.
-
#info(msg = nil) { ... } ⇒ void
Log a message at info level.
-
#info? ⇒ true, false
If the logger is enabled at info level.
- #inspect ⇒ String (also: #to_s)
-
#log_exception(exception) ⇒ void
Print error and stack trace without calls to internal classes.
-
#name ⇒ String
The logger name.
-
#trace(msg = nil) { ... } ⇒ void
Log a message at trace level.
-
#trace? ⇒ true, false
If the logger is enabled at trace level.
-
#warn(msg = nil) { ... } ⇒ void
Log a message at warn level.
-
#warn? ⇒ true, false
If the logger is enabled at warn level.
Instance Attribute Details
#level ⇒ :error, ...
When a logger’s level is modified, the logging infrastructure has to reload, and logging may be completely unavailable for a short time.
Returns The current log level.
283 284 285 |
# File 'lib/openhab/log.rb', line 283 def level Logger.log_service.get_level(name)[name]&.downcase&.to_sym end |
Class Method Details
.events ⇒ Logger
The events logger (events.log)
199 200 201 |
# File 'lib/openhab/log.rb', line 199 def events Log.logger("openhab.event") end |
Instance Method Details
#debug(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at debug level.
299 |
# File 'lib/openhab/log.rb', line 299 def_level_method(:debug) |
#debug? ⇒ true, false
If the logger is enabled at debug level.
300 |
# File 'lib/openhab/log.rb', line 300 def_level_predicate(:debug) |
#error(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at error level.
293 |
# File 'lib/openhab/log.rb', line 293 def_level_method(:error) |
#error? ⇒ true, false
If the logger is enabled at error level.
294 |
# File 'lib/openhab/log.rb', line 294 def_level_predicate(:error) |
#info(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at info level.
297 |
# File 'lib/openhab/log.rb', line 297 def_level_method(:info) |
#info? ⇒ true, false
If the logger is enabled at info level.
298 |
# File 'lib/openhab/log.rb', line 298 def_level_predicate(:info) |
#inspect ⇒ String Also known as: to_s
264 265 266 |
# File 'lib/openhab/log.rb', line 264 def inspect "#<OpenHAB::Logger #{name}>" end |
#log_exception(exception) ⇒ void
This method returns an undefined value.
Print error and stack trace without calls to internal classes
310 311 312 313 314 315 |
# File 'lib/openhab/log.rb', line 310 def log_exception(exception) exception = clean_backtrace(exception) error do "#{exception.} (#{exception.class})\n#{exception.backtrace&.join("\n")}" end end |
#name ⇒ String
The logger name
259 260 261 |
# File 'lib/openhab/log.rb', line 259 def name @slf4j_logger.name end |
#trace(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at trace level.
301 |
# File 'lib/openhab/log.rb', line 301 def_level_method(:trace) |
#trace? ⇒ true, false
If the logger is enabled at trace level.
302 |
# File 'lib/openhab/log.rb', line 302 def_level_predicate(:trace) |
#warn(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at warn level.
295 |
# File 'lib/openhab/log.rb', line 295 def_level_method(:warn) |
#warn? ⇒ true, false
If the logger is enabled at warn level.
296 |
# File 'lib/openhab/log.rb', line 296 def_level_predicate(:warn) |