Skip to content

Commit 2b389e0

Browse files
committed
Cleanup, align with existing guidelines, link.
1 parent a592102 commit 2b389e0

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/guidelines/checklist/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [ ] Panic Means 'Stop the Program' ([M-PANIC-IS-STOP])
1515
- [ ] Detected Programming Bugs are Panics, Not Errors ([M-PANIC-ON-BUG])
1616
- [ ] All Magic Values and Behaviors are Documented ([M-DOCUMENTED-MAGIC])
17+
- [ ] Use Structured Logging with Message Templates ([M-LOG-STRUCTURED])
1718
- **Library / Interoperability**
1819
- [ ] Types are Send ([M-TYPES-SEND])
1920
- [ ] Native Escape Hatches ([M-ESCAPE-HATCHES])
@@ -73,6 +74,7 @@
7374
[M-PANIC-IS-STOP]: ../universal/#M-PANIC-IS-STOP
7475
[M-PANIC-ON-BUG]: ../universal/#M-PANIC-ON-BUG
7576
[M-DOCUMENTED-MAGIC]: ../universal/#M-DOCUMENTED-MAGIC
77+
[M-LOG-STRUCTURED]: ../universal/#M-LOG-STRUCTURED
7678

7779
<!-- Libs -->
7880
[M-TYPES-SEND]: ../libs/interop/#M-TYPES-SEND

src/guidelines/universal/M-LOG-STRUCTURED.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ String formatting allocates memory at runtime. Message templates defer formattin
1818
We recommend that message template includes all named properties for easier inspection at viewing time.
1919

2020
```rust,ignore
21-
// DON'T: String formatting causes allocations
21+
// Bad: String formatting causes allocations
2222
tracing::info!("file opened: {}", path);
2323
tracing::info!(format!("file opened: {}", path));
2424
25-
// DO: Use message templates with named properties
25+
// Good: Message templates with named properties
2626
event!(
2727
name: "file.open.success",
2828
Level::INFO,
@@ -31,25 +31,22 @@ event!(
3131
);
3232
```
3333

34-
> **Note**: Use `{{property}}` syntax in message templates. Double braces preserve the literal text
34+
> **Note**: Use `{{property}}` the syntax in message templates which preserves the literal text
3535
> while escaping Rust's format syntax. String formatting is deferred until logs are viewed.
36-
>
37-
> This pattern may trigger Clippy's [`literal_string_with_formatting_args`](https://rust-lang.github.io/rust-clippy/stable/index.html#literal_string_with_formatting_args)
38-
> warning so consider suppressing it for logging.
3936
4037
### Name Your Events
4138

4239
Use hierarchical dot-notation: `<component>.<operation>.<state>`
4340

4441
```rust,ignore
45-
// DON'T: Unnamed events
42+
// Bad: Unnamed events
4643
event!(
4744
Level::INFO,
4845
file.path = file_path,
4946
"file {{file.path}} processed succesfully",
5047
);
5148
52-
// DO: Named events
49+
// Good: Named events
5350
event!(
5451
name: "file.processing.success", // event identifier
5552
Level::INFO,
@@ -90,7 +87,7 @@ Common conventions:
9087
Do not log plain sensitive data as this might lead to privacy and security incidents.
9188

9289
```rust,ignore
93-
// DON'T: Log potentially sensitive data
90+
// Bad: Logs potentially sensitive data
9491
event!(
9592
name: "file.operation.started",
9693
Level::INFO,
@@ -99,7 +96,7 @@ event!(
9996
"reading file {{file.name}} for user {{user.email}}",
10097
);
10198
102-
// DO: Redact sensitive parts
99+
// Good: Redact sensitive parts
103100
event!(
104101
name: "file.operation.started",
105102
Level::INFO,
@@ -110,9 +107,7 @@ event!(
110107
```
111108

112109
Sensitive data include user email, file paths revealing user identity, filenames containing secrets or tokens,
113-
file contents with PII, temporary file paths with session IDs and more.
114-
115-
Consider using the [`data_privacy`](https://crates.io/crates/data_privacy) crate for consistent redaction.
110+
file contents with PII, temporary file paths with session IDs and more. Consider using the [`data_privacy`](https://crates.io/crates/data_privacy) crate for consistent redaction.
116111

117112
### Further Reading
118113

src/guidelines/universal/M-STATIC-VERIFICATION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ unnecessary_safety_doc = "warn"
7373
unneeded_field_pattern = "warn"
7474
unused_result_ok = "warn"
7575

76+
# May cause issues with structured logging otherwise.
77+
literal_string_with_formatting_args = "allow"
78+
7679
# Define custom opt outs here
7780
# ...
7881
```

0 commit comments

Comments
 (0)