rails 8.0.2 to 8.1. lograte for logging.

This commit is contained in:
Christoph Haas 2026-02-25 00:09:25 +01:00
parent 4e0858ccbe
commit 9236af0712
20 changed files with 536 additions and 321 deletions

View file

@ -17,17 +17,16 @@ Rails.application.configure do
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
# Run rails dev:cache to toggle Action Controller caching.
# if Rails.root.join('tmp/caching-dev.txt').exist?
# config.action_controller.perform_caching = true
# config.action_controller.enable_fragment_cache_logging = true
# config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" }
# else
# config.action_controller.perform_caching = false
# end
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
end
# Change to :null_store to avoid any caching.
# config.cache_store = :memory_store
config.cache_store = :null_store
config.cache_store = :memory_store
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
@ -65,11 +64,23 @@ Rails.application.configure do
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
# Highlight code that triggered redirect in logs.
config.action_dispatch.verbose_redirect_logs = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
config.action_view.annotate_rendered_view_with_filenames = true
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
@ -96,18 +107,9 @@ Rails.application.configure do
# TODO: put it into the database and make it configurable online
config.alert_message = ENV['DEBSHOTS_ALERT_MESSAGE']
# URL to fetch reviews from the Ubuntu JSON API
# config.ubuntu_reviews_api_url = 'https://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/en/any/any/any/%s'
# Needed (at least) for devise.rb to determine the oauth2 callback URL
config.base_url = ENV['DEBSHOTS_BASE_URL'] || 'http://localhost:3000'
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
# config.generators.apply_rubocop_autocorrect_after_generate!
end

View file

@ -25,10 +25,10 @@ Rails.application.configure do
config.active_storage.service = :local
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
config.assume_ssl = true
# config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
# config.force_ssl = true
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
@ -37,7 +37,16 @@ Rails.application.configure do
config.log_tags = [:request_id]
config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
# Change to "debug" to log everything (including potentially personally-identifiable information!)
# Lograge - structured request logging
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
{
request_id: event.payload[:request_id],
user_id: event.payload[:user_id]
}
end
# Change to "debug" to log everything (including potentially personally-identifiable information!).
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
# Prevent health checks from clogging up the logs.
@ -47,20 +56,10 @@ Rails.application.configure do
config.active_support.report_deprecations = false
# Replace the default in-process memory cache store with a durable alternative.
# config.cache_store = :solid_cache_store
# config.cache_store = :mem_cache_store
# Replace the default in-process and non-durable queuing backend for Active Job.
# config.active_job.queue_adapter = :solid_queue
# config.solid_queue.connects_to = { database: { writing: :queue } }
config.action_mailer.smtp_settings = {
address: ENV['SMTP_SERVER'],
port: 25,
enable_starttls_auto: false
}
config.action_mailer.default_url_options = {
host: 'screenshots.debian.net',
protocol: 'https'
}
# config.active_job.queue_adapter = :resque
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -69,7 +68,7 @@ Rails.application.configure do
# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: 'example.com' }
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
# Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit.
# config.action_mailer.smtp_settings = {
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
# password: Rails.application.credentials.dig(:smtp, :password),
@ -85,6 +84,18 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Only use :id for inspections in production.
config.active_record.attributes_for_inspect = [:id]
# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
#
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
# Let the "thrust" web server handle sending images. It allows to route all
# images through the Rails application and prevent unauthorized access to
# images that are pending moderation. (A common problem with spammers uploading
@ -106,23 +117,6 @@ Rails.application.configure do
# TODO: put it into the database and make it configurable online
config.alert_message = ENV['DEBSHOTS_ALERT_MESSAGE']
# URL to fetch reviews from the Ubuntu JSON API
# config.ubuntu_reviews_api_url = 'https://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/en/any/any/any/%s'
# Any action dealing with authentication should redirect to HTTPS
# Disabled because it will redirect incorrectly behind a proxy.
# config.to_prepare { Devise::SessionsController.force_ssl }
# Only use :id for inspections in production.
# Needed (at least) for devise.rb to determine the oauth2 callback URL
config.base_url = ENV['DEBSHOTS_BASE_URL'] || 'http://localhost:3000'
config.active_record.attributes_for_inspect = [:id]
# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
#
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
end

View file

@ -62,10 +62,8 @@ Rails.application.configure do
config.alert_message = ENV['DEBSHOTS_ALERT_MESSAGE']
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.base_url = ENV['DEBSHOTS_BASE_URL'] || 'http://localhost:3000'
# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true
end