Module: Mirah::Logging::Logged

Defined in:
lib/mirah/util/logging.rb

Constant Summary collapse

VLEVELS =
[Level::CONFIG, Level::FINE, Level::FINER, Level::FINEST]

Instance Method Summary collapse

Instance Method Details

#error(*args) ⇒ Object



21
22
23
# File 'lib/mirah/util/logging.rb', line 21

def error(*args)
  logger.log(Level::SEVERE, *args)
end

#info(*args) ⇒ Object



29
30
31
# File 'lib/mirah/util/logging.rb', line 29

def info(*args)
  logger.log(Level::INFO, *args)
end

#log(*args) ⇒ Object



33
34
35
# File 'lib/mirah/util/logging.rb', line 33

def log(*args)
  vlog(1, *args)
end

#loggerObject



12
13
14
# File 'lib/mirah/util/logging.rb', line 12

def logger
  @logger ||= java.util.logging.Logger.getLogger(logger_name)
end

#logger_nameObject



16
17
18
19
# File 'lib/mirah/util/logging.rb', line 16

def logger_name
  name = self.class.name.sub(/^Mirah::/, '').gsub('::', '.')
  "org.mirah.ruby.#{name}"
end

#logging?(level = Level::FINE) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/mirah/util/logging.rb', line 37

def logging?(level=Level::FINE)
  level = VLEVELS[level] unless level.kind_of?(Level)
  logger.isLoggable(level)
end

#vlog(level, *args) ⇒ Object



42
43
44
# File 'lib/mirah/util/logging.rb', line 42

def vlog(level, *args)
  logger.log(VLEVELS[level], *args)
end

#warning(*args) ⇒ Object



25
26
27
# File 'lib/mirah/util/logging.rb', line 25

def warning(*args)
  logger.log(Level::WARNING, *args)
end