lib/semantic_logger/levels.rb in semantic_logger-4.6.1 vs lib/semantic_logger/levels.rb in semantic_logger-4.7.0
- old
+ new
@@ -14,20 +14,22 @@
elsif level.is_a?(String)
level = level.downcase.to_sym
LEVELS.index(level)
elsif level.is_a?(Integer) && defined?(::Logger::Severity)
# Mapping of Rails and Ruby Logger levels to SemanticLogger levels
- @map_levels ||= begin
- levels = []
- ::Logger::Severity.constants.each do |constant|
- levels[::Logger::Severity.const_get(constant)] =
- LEVELS.find_index(constant.downcase.to_sym) || LEVELS.find_index(:error)
+ @map_levels ||=
+ begin
+ levels = []
+ ::Logger::Severity.constants.each do |constant|
+ levels[::Logger::Severity.const_get(constant)] =
+ LEVELS.find_index(constant.downcase.to_sym) || LEVELS.find_index(:error)
+ end
+ levels
end
- levels
- end
@map_levels[level]
end
raise "Invalid level:#{level.inspect} being requested. Must be one of #{LEVELS.inspect}" unless index
+
index
end
# Returns the symbolic level for the supplied level index
def self.level(level_index)