Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Render backtrace for debug log level through LogDelegator (#9475)

Oliver Günthera2244ca70a5d
diff --git a/lib/open_project/logging/log_delegator.rb b/lib/open_project/logging/log_delegator.rb
index 8d4e83416f7..37e88d45897 100644
--- a/lib/open_project/logging/log_delegator.rb
+++ b/lib/open_project/logging/log_delegator.rb
@@ -48,7 +48,7 @@ module OpenProject
def clean_backtrace(exception)
return nil unless exception&.backtrace
- Rails.backtrace_cleaner.clean exception.backtrace, :full
+ Rails.backtrace_cleaner.clean exception.backtrace
end
##
@@ -84,10 +84,17 @@ module OpenProject
# A lambda handler for logging the error
# to rails.
def rails_logger_handler(message, context = {})
- Rails.logger.public_send(
- context[:level],
+ Rails.logger.public_send(context[:level]) do
"#{context_string(context)} #{message}"
- )
+ end
+
+ if context.key?(:exception)
+ Rails.logger.debug do
+ exception = context[:exception]
+ trace = context[:backtrace]&.join('; ')
+ "[#{exception.class}] #{exception.message}: #{trace}"
+ end
+ end
end
##