Class: Rsg::Generators::Logging::LogrageGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rsg/generators/logging/lograge_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_logrageObject



6
7
8
9
# File 'lib/rsg/generators/logging/lograge_generator.rb', line 6

def add_lograge
  append_gem "lograge", install: false
  append_gem "logstash-event", after: "lograge"
end


2
3
4
# File 'lib/rsg/generators/logging/lograge_generator.rb', line 2

def banner
  say "Configuring lograge with JSON logging"
end

#initializerObject



11
12
13
# File 'lib/rsg/generators/logging/lograge_generator.rb', line 11

def initializer
  copy_file "initializer_lograge.rb", "config/initializers/logging.rb"
end

#json_logs_env_varObject



15
16
17
18
19
20
# File 'lib/rsg/generators/logging/lograge_generator.rb', line 15

def json_logs_env_var
  inject_into_file "config/application.rb", <<-CODE, before: /^  end$/
\n    # Enable JSON logs with lograge
  config.x.json_logs = Rails.env.production? || %w[1 true yes].include?(ENV.fetch('JSON_LOGS', '0'))
  CODE
end