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.
253 254 255 |
# File 'lib/openhab/log.rb', line 253 def level Logger.log_service.get_level(name)[name]&.downcase&.to_sym end |
Class Method Details
.events ⇒ Logger
The events logger (events.log)
169 170 171 |
# File 'lib/openhab/log.rb', line 169 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.
269 |
# File 'lib/openhab/log.rb', line 269 def_level_method(:debug) |
#debug? ⇒ true, false
If the logger is enabled at debug level.
270 |
# File 'lib/openhab/log.rb', line 270 def_level_predicate(:debug) |
#error(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at error level.
263 |
# File 'lib/openhab/log.rb', line 263 def_level_method(:error) |
#error? ⇒ true, false
If the logger is enabled at error level.
264 |
# File 'lib/openhab/log.rb', line 264 def_level_predicate(:error) |
#info(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at info level.
267 |
# File 'lib/openhab/log.rb', line 267 def_level_method(:info) |
#info? ⇒ true, false
If the logger is enabled at info level.
268 |
# File 'lib/openhab/log.rb', line 268 def_level_predicate(:info) |
#inspect ⇒ String Also known as: to_s
234 235 236 |
# File 'lib/openhab/log.rb', line 234 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
280 281 282 283 284 285 |
# File 'lib/openhab/log.rb', line 280 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
229 230 231 |
# File 'lib/openhab/log.rb', line 229 def name @slf4j_logger.name end |
#trace(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at trace level.
271 |
# File 'lib/openhab/log.rb', line 271 def_level_method(:trace) |
#trace? ⇒ true, false
If the logger is enabled at trace level.
272 |
# File 'lib/openhab/log.rb', line 272 def_level_predicate(:trace) |
#warn(msg = nil) { ... } ⇒ void
This method returns an undefined value.
Log a message at warn level.
265 |
# File 'lib/openhab/log.rb', line 265 def_level_method(:warn) |
#warn? ⇒ true, false
If the logger is enabled at warn level.
266 |
# File 'lib/openhab/log.rb', line 266 def_level_predicate(:warn) |