module SemanticLogger
def self.silence(new_level = :error)
#silence does not affect any loggers which have had their log level set
Note:
end
logger.error "but errors will be logged"
logger.warn "this neither"
logger.info "this will _not_ be logged"
SemanticLogger.silence do
# Silence all logging for this thread below :error level
Example:
Default: :error
The new log level to apply within the block
new_level
Parameters
end
logger.debug "this will be logged"
SemanticLogger.silence(:trace) do
logger.debug 'this will _not_ be logged'
SemanticLogger.default_level = :info
# Perform trace level logging within the block when the default is higher
Example:
the supplied block.
#silence can be used to both raise and lower the log level within
Any threads spawned within the block will not be affected by this setting
This setting is thread-safe and only applies to the current thread
Silence noisy log levels by changing the default_level within the block
def self.silence(new_level = :error) current_index = Thread.current[:semantic_logger_silence] Thread.current[:semantic_logger_silence] = Levels.index(new_level) yield ensure Thread.current[:semantic_logger_silence] = current_index end