Class: Spark::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/spark/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

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

#jloggerObject (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(message)
  jlogger.debug(message) if debug?
end

#debug?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/spark/logger.rb', line 53

def debug?
  level_enabled?('debug')
end

#disableObject

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

Returns:

  • (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(message)
  jlogger.error(message) if error?
end

#error?Boolean

Returns:

  • (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(message)
  jlogger.info(message) if info?
end

#info?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/spark/logger.rb', line 49

def info?
  level_enabled?('info')
end

#level_enabled?(type) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/spark/logger.rb', line 69

def level_enabled?(type)
  jlogger.isEnabledFor(JPriority.toPriority(type.upcase))
end

#level_offObject



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(message)
  jlogger.trace(message) if trace?
end

#trace?Boolean

Returns:

  • (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(message)
  jlogger.warn(message) if warning?
end

#warning?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/spark/logger.rb', line 61

def warning?
  level_enabled?('warn')
end