Class: Spark::Logger
- Inherits:
-
Object
- Object
- Spark::Logger
- Defined in:
- lib/spark/logger.rb
Instance Attribute Summary collapse
-
#jlogger ⇒ Object
readonly
Returns the value of attribute jlogger.
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #debug? ⇒ Boolean
-
#disable ⇒ Object
Disable all Spark log.
- #enabled? ⇒ Boolean
- #error(message) ⇒ Object
- #error? ⇒ Boolean
- #info(message) ⇒ Object
- #info? ⇒ Boolean
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
- #level_enabled?(type) ⇒ Boolean
- #level_off ⇒ Object
- #trace(message) ⇒ Object
- #trace? ⇒ Boolean
- #warning(message) ⇒ Object (also: #warn)
- #warning? ⇒ Boolean
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
9 10 11 |
# File 'lib/spark/logger.rb', line 9 def initialize @jlogger = JLogger.getLogger('Ruby') end |
Instance Attribute Details
#jlogger ⇒ Object (readonly)
Returns the value of attribute jlogger.
7 8 9 |
# File 'lib/spark/logger.rb', line 7 def jlogger @jlogger end |
Instance Method Details
#debug(message) ⇒ Object
33 34 35 |
# File 'lib/spark/logger.rb', line 33 def debug() jlogger.debug() if debug? end |
#debug? ⇒ Boolean
53 54 55 |
# File 'lib/spark/logger.rb', line 53 def debug? level_enabled?('debug') end |
#disable ⇒ Object
Disable all Spark log
18 19 20 21 22 23 |
# File 'lib/spark/logger.rb', line 18 def disable jlogger.setLevel(level_off) JLogger.getLogger('org').setLevel(level_off) JLogger.getLogger('akka').setLevel(level_off) JLogger.getRootLogger.setLevel(level_off) end |
#enabled? ⇒ Boolean
25 26 27 |
# File 'lib/spark/logger.rb', line 25 def enabled? !disabled? end |
#error(message) ⇒ Object
45 46 47 |
# File 'lib/spark/logger.rb', line 45 def error() jlogger.error() if error? end |
#error? ⇒ Boolean
65 66 67 |
# File 'lib/spark/logger.rb', line 65 def error? level_enabled?('error') end |
#info(message) ⇒ Object
29 30 31 |
# File 'lib/spark/logger.rb', line 29 def info() jlogger.info() if info? end |
#info? ⇒ Boolean
49 50 51 |
# File 'lib/spark/logger.rb', line 49 def info? level_enabled?('info') end |
#level_enabled?(type) ⇒ Boolean
69 70 71 |
# File 'lib/spark/logger.rb', line 69 def level_enabled?(type) jlogger.isEnabledFor(JPriority.toPriority(type.upcase)) end |
#level_off ⇒ Object
13 14 15 |
# File 'lib/spark/logger.rb', line 13 def level_off JLevel.toLevel('OFF') end |
#trace(message) ⇒ Object
37 38 39 |
# File 'lib/spark/logger.rb', line 37 def trace() jlogger.trace() if trace? end |
#trace? ⇒ Boolean
57 58 59 |
# File 'lib/spark/logger.rb', line 57 def trace? level_enabled?('trace') end |
#warning(message) ⇒ Object Also known as: warn
41 42 43 |
# File 'lib/spark/logger.rb', line 41 def warning() jlogger.warn() if warning? end |
#warning? ⇒ Boolean
61 62 63 |
# File 'lib/spark/logger.rb', line 61 def warning? level_enabled?('warn') end |