ConsoleSourceConsoleFilter

class Filter

Definitions

def enabled?(subject, level = self.class::MINIMUM_LEVEL)

You can enable and disable logging for classes. This function checks if logging for a given subject is enabled.

Implementation

def enabled?(subject, level = self.class::MINIMUM_LEVEL)
	subject = subject.class unless subject.is_a?(Module)
	
	if specific_level = @subjects[subject]
		return level >= specific_level
	end
	
	if level >= @level
		return true
	end
end

def enable(subject, level = self.class::MINIMUM_LEVEL)

Enable specific log level for the given class.

Signature

parameter name Module

The class to enable.

Implementation

def enable(subject, level = self.class::MINIMUM_LEVEL)
	# Set the filter level of logging for a given subject which passes all log messages:
	filter(subject, level)
end

def clear(subject)

Clear any specific filters for the given class.

Signature

parameter name Module

The class to disable.

Implementation

def clear(subject)
	unless subject.is_a?(Module)
		raise ArgumentError, "Expected a class, got #{subject.inspect}"
	end
	
	@subjects.delete(subject)
end