Class: Wafris::LogSuppressor

Inherits:
Object
  • Object
show all
Defined in:
lib/wafris/log_suppressor.rb

Class Method Summary collapse

Class Method Details

.current_environmentObject



18
19
20
21
22
23
24
# File 'lib/wafris/log_suppressor.rb', line 18

def self.current_environment
  if defined?(Rails)
    Rails.env
  else
    ENV["RACK_ENV"] || "development"
  end
end

.puts_log(message) ⇒ Object



5
6
7
# File 'lib/wafris/log_suppressor.rb', line 5

def self.puts_log(message)
  puts("[Wafris] " + message) unless suppress_logs?
end

.suppress_logs?Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/wafris/log_suppressor.rb', line 9

def self.suppress_logs?
  suppressed_environments.include?(current_environment) ||
    (ENV["WAFRIS_LOG_LEVEL"] && ENV["WAFRIS_LOG_LEVEL"] == "silent")
end

.suppressed_environmentsObject



14
15
16
# File 'lib/wafris/log_suppressor.rb', line 14

def self.suppressed_environments
  ["test"] + (ENV["CI"] ? ["CI"] : [])
end