Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gem 'flipflop'
gem 'jquery-rails'
gem 'json'
gem 'kaminari'
gem 'lograge'
gem 'marc'
gem 'mitlibraries-theme', git: 'https://github.com/mitlibraries/mitlibraries-theme', tag: 'v1.5'
gem 'net-imap', require: false
Expand All @@ -31,6 +30,7 @@ gem 'omniauth-saml'
gem 'paper_trail'
gem 'puma'
gem 'rails', '~> 8.1.0'
gem 'rails_semantic_logger'
gem 'rubyzip'
gem 'sass-rails'
gem 'sentry-rails'
Expand All @@ -55,6 +55,7 @@ group :development, :test do
end

group :development do
gem 'amazing_print'
gem 'annotaterb'
gem 'dotenv-rails'
gem 'letter_opener'
Expand Down
15 changes: 9 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ GEM
actionview (>= 6.0, < 9.0)
activerecord (>= 6.0, < 9.0)
kaminari (~> 1.2.2)
amazing_print (3.0.0)
annotaterb (4.24.0)
activerecord (>= 6.0.0)
activesupport (>= 6.0.0)
Expand Down Expand Up @@ -222,11 +223,6 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.7.0)
lograge (0.15.0)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.25.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -326,6 +322,10 @@ GEM
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
rails-mermaid_erd (0.8.0)
rails (>= 5.2)
rails_semantic_logger (5.2.0)
rack
railties (>= 7.2)
semantic_logger (>= 5.1)
railties (8.1.3.1)
actionpack (= 8.1.3.1)
activesupport (= 8.1.3.1)
Expand Down Expand Up @@ -402,6 +402,8 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 4.0)
websocket (~> 1.0)
semantic_logger (5.1.0)
concurrent-ruby (~> 1.0)
sentry-rails (6.7.0)
railties (>= 5.2.0)
sentry-ruby (~> 6.7.0)
Expand Down Expand Up @@ -468,6 +470,7 @@ PLATFORMS

DEPENDENCIES
administrate (~> 1.0.0)
amazing_print
annotaterb
aws-sdk-rails
aws-sdk-s3
Expand All @@ -490,7 +493,6 @@ DEPENDENCIES
kaminari
letter_opener
listen
lograge
marc
minitest (< 6)
minitest-reporters
Expand All @@ -505,6 +507,7 @@ DEPENDENCIES
puma
rails (~> 8.1.0)
rails-mermaid_erd
rails_semantic_logger
rubocop
rubocop-rails
rubyzip
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ postgres config.

## Environment variables

`DISABLE_LOGRAGE` - set this in to disable lograge single line logging config
and use rails standard verbose logging.

`JS_EXCEPTION_LOGGER_KEY` - set this to the value of the exception monitor
public post key to enable capturing javascript exceptions.

`LOG_LEVEL` - we set sane defaults in development or production, but you can
`RAILS_LOG_LEVEL` - we set sane defaults in development or production, but you can
override easily with this ENV if you need to get more details.
`RAILS_APP_NAME` - overrides the application name used by semantic logger in
structured log output.
`SEMANTIC_LOGGER_MULTILINE` - enables multiline semantic logger output in staging.

`MAINTENANCE_MODE` - this toggles a [Flipflop feature](https://github.com/voormedia/flipflop) that disables thesis
transfers and informs transfer submitters that the application is under maintenance.
Expand All @@ -107,9 +107,6 @@ requests that come to the app will redirect to the root of this domain. This is
useful to prevent access to herokuapp.com domains as well as any legacy domains
you'd like to handle.

`RAILS_LOG_TO_STDOUT` - log to standard out instead of a file. Heroku enables
this automatically. It is often nice in development as well.

`SENTRY_DSN` - set to your project sentry key to enable exception logging
`SENTRY_ENV` - Sentry environment for the application. Defaults to 'unknown' if unset.

Expand Down
15 changes: 6 additions & 9 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,13 @@
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

# allow configurable log levels, default to debug
config.log_level = ENV['LOG_LEVEL'] || :debug
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "debug")

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
# Configure Rails Semantic Logger
Comment thread
JPrevost marked this conversation as resolved.
multiline = ENV.fetch("SEMANTIC_LOGGER_MULTILINE", "true").downcase == "true"
config.rails_semantic_logger.appenders do |appenders|
# appenders.add(file_name: "log/#{Rails.env}.log", formatter: :color) # uncomment to log to file
appenders.add(io: $stdout, formatter: { color: { ap: { multiline: multiline }}})
end

# Annotate rendered view with file names.
Expand Down
13 changes: 8 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }

# Log to STDOUT by default
config.log_tags = [ :request_id ]
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
# Include request ID as a structured field.
config.log_tags = { request_id: :request_id }

# Change to "debug" to log everything (including potentially personally-identifiable information!).
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")

# Configure Rails Semantic Logger to log to STDOUT in JSON format
SemanticLogger.application = ENV.fetch("RAILS_APP_NAME", "thing")
config.rails_semantic_logger.appenders do |appenders|
appenders.add(io: $stdout, formatter: :json)
end

# Prevent health checks from clogging up the logs.
config.silence_healthcheck_path = "/up"

Expand Down
20 changes: 0 additions & 20 deletions config/initializers/lograge.rb

This file was deleted.