You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,10 +97,10 @@ And you always need to check for any third-party gems that are not part of Rails
97
97
98
98
- Use Sorbet type annotations for all methods
99
99
- Ensure all files have the appropriate `# typed:` annotation
100
-
-**NEVER use `T.unsafe` calls**. Instead, properly type your code or use appropriate type assertions with`T.let` or `T.cast` when absolutely necessary.
100
+
-Prefer precise types and `T.let`/`T.cast` over `T.unsafe`. If a Sorbet limitation requires it (e.g., splat with callbacks, serializing unknown external objects), a minimal, localized`T.unsafe` may be used with a brief comment explaining why.
101
101
-`T.untyped` is generally ok for Hash values when they come from unknown sources.
102
-
- When dealing with external libraries, create proper type signatures or use extension methods rather than resorting to `T.unsafe`.
103
-
-**NEVER use `class.name`** anywhere - this is a Sorbet quirk that hides the `name` method from all base classes. Prefer just using Classes themselves as the type. `"#{class}"` will automatically call `.to_s`. Similarly, `to_json` will automatically call `.to_s` - but you can call `.to_s` manually if you really need it.
102
+
- When dealing with external libraries, create proper type signatures or use extension methods; keep `T.unsafe` usage small and justified.
103
+
-Avoid `class.name` where possible due to Sorbet quirks; prefer string interpolation (`"#{klass}"`) or use the class as a value.
Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# LogStruct
2
2
3
-
Adds JSON structured logging to any Rails app. Simply add the gem to your Gemfile and add an initializer to configure it. Now your Rails app prints beautiful JSON logs to STDOUT. They're easy to search and filter, you can turn them into metrics and alerts, and they're great for building dashboards in CloudWatch, Grafana, or Datadog.
3
+
Adds JSON structured logging to any Rails app. Simply add the gem to your Gemfile and add an initializer to configure it. By default, your Rails app prints JSON logs to STDOUT (or to the configured destination when `RAILS_LOG_TO_STDOUT` is set). They're easy to search and filter, you can turn them into metrics and alerts, and they're great for building dashboards in CloudWatch, Grafana, or Datadog.
4
4
5
5
We support all your other favorite gems too, like Sidekiq, Sentry, and Shrine. (And if not, please open a PR!)
6
6
@@ -14,7 +14,7 @@ We support all your other favorite gems too, like Sidekiq, Sentry, and Shrine. (
14
14
- Error handling and reporting
15
15
- Metadata collection for rich context
16
16
- Lograge integration for structured request logging
17
-
- Sensitive data scrubbing with Logstop (vendored fork)
17
+
- Sensitive data scrubbing for strings (inspired by the Logstop gem)
18
18
- Host authorization logging for security violations
19
19
- Rack middleware for enhanced error logging
20
20
- ActionMailer delivery callbacks for Rails 7.0.x (backported from Rails 7.1)
@@ -46,7 +46,7 @@ LogStruct is designed to be highly opinionated and work out of the box with mini
46
46
47
47
Please see the [documentation](https://logstruct.com/docs/configuration/) for configuration options.
48
48
49
-
### Important Note on Integration
49
+
### Important Notes on Integration
50
50
51
51
Once initialized, the gem automatically includes its modules into the appropriate base classes:
52
52
@@ -55,6 +55,8 @@ Once initialized, the gem automatically includes its modules into the appropriat
55
55
- We configure `Lograge` for request logging
56
56
- A Rack middleware is inserted to catch and log errors, including security violations (IP spoofing, CSRF, blocked hosts, etc.)
57
57
- Structured logging is set up for ActiveJob, Sidekiq, Shrine, etc.
58
+
- Rails `config.filter_parameters` are merged into LogStruct's filters and then cleared (to avoid double filtering). Configure sensitive keys via `LogStruct.config.filters`.
59
+
- When `RAILS_LOG_TO_STDOUT` is set, we log to STDOUT only. Otherwise, we log to STDOUT by default without adding a file appender to avoid duplicate logs.
0 commit comments