Module: Mirah::Logging::Logged

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#error(*args) ⇒ Object



84
85
86
# File 'lib/mirah/util/logging.rb', line 84

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

#info(*args) ⇒ Object



92
93
94
# File 'lib/mirah/util/logging.rb', line 92

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

#log(*args) ⇒ Object



96
97
98
# File 'lib/mirah/util/logging.rb', line 96

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

#loggerObject



75
76
77
# File 'lib/mirah/util/logging.rb', line 75

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

#logger_nameObject



79
80
81
82
# File 'lib/mirah/util/logging.rb', line 79

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

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

Returns:

  • (Boolean)


100
101
102
103
# File 'lib/mirah/util/logging.rb', line 100

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

#vlog(level, *args) ⇒ Object



105
106
107
# File 'lib/mirah/util/logging.rb', line 105

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

#warning(*args) ⇒ Object



88
89
90
# File 'lib/mirah/util/logging.rb', line 88

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