actindi / act-fluent-logger-rails

Fluent logger
MIT License
118 stars 72 forks source link

Fix for Issue #41: Error logging session variable - 'undefined method []=' for nil:NilClass #74

Open sampokuokkanen opened 1 year ago

sampokuokkanen commented 1 year ago

This PR addresses issue #41, where an 'undefined method `[]=' for nil:NilClass' error was encountered when attempting to log session variables.

The root cause of the issue was a lack of access to the session data in the logger.

In this PR, I have:

Refactored the logger's interaction with the session data. This ensures the logger has access to the session when you have loaded the middleware.

Introduced a dummy Rails application to the codebase.

Updated RSpec to the latest version and added tests to verify that session variables can be logged successfully.

Improved the README file with more detailed instructions and clear guidelines on how to access the session in the logger.

With these changes, the logger is now able to correctly access and log the uid field from the session in fluentd logs, as expected.

Feedback on these changes is appreciated.