Skip to content

Commit

Permalink
[SUPPORT] Added Current Thread Name Support In Logging as Mentioned i…
Browse files Browse the repository at this point in the history
…n Documentations at https://actix.rs/docs/middleware/
  • Loading branch information
Atri10 committed Apr 10, 2024
1 parent 5a5486b commit 1d990a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions actix-web/src/middleware/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
pin::Pin,

Check warning on line 10 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / fmt

Diff in /home/runner/work/actix-web/actix-web/actix-web/src/middleware/logger.rs
rc::Rc,
task::{Context, Poll},
thread::current
};

use actix_service::{Service, Transform};
Expand Down Expand Up @@ -512,6 +513,7 @@ impl Format {
"U" => FormatText::UrlPath,
"T" => FormatText::Time,
"D" => FormatText::TimeMillis,
"P" => FormatText::ThreadName,
_ => FormatText::Str(m.as_str().to_owned()),
});
}
Expand All @@ -531,6 +533,7 @@ impl Format {
#[derive(Debug, Clone)]
enum FormatText {
Str(String),
ThreadName,

Check failure on line 536 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] reported by reviewdog 🐶 error[E0532]: expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName` --> actix-web/src/middleware/logger.rs:616:13 | 536 | ThreadName, | ---------- `FormatText::ThreadName` defined here ... 616 | FormatText::ThreadName() => { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FormatText::ThreadName` Raw Output: actix-web/src/middleware/logger.rs:536:5:e:error[E0532]: expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName` --> actix-web/src/middleware/logger.rs:616:13 | 536 | ThreadName, | ---------- `FormatText::ThreadName` defined here ... 616 | FormatText::ThreadName() => { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FormatText::ThreadName` __END__
Percent,
RequestLine,
RequestTime,
Expand Down Expand Up @@ -610,6 +613,9 @@ impl FormatText {
"-".fmt(fmt)
}
}
FormatText::ThreadName() => {

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / io-uring tests

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / public-api-diff

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / Linux / msrv

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / doc tests

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / lint-docs

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / Linux / stable

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / macOS / msrv

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / macOS / stable

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / Windows / msrv

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`

Check failure on line 616 in actix-web/src/middleware/logger.rs

View workflow job for this annotation

GitHub Actions / Windows / stable

expected tuple struct or tuple variant, found unit variant `FormatText::ThreadName`
fmt.write_fmt(format_args!("{}", current().name().unwrap()))
}
_ => Ok(()),
}
}
Expand Down

0 comments on commit 1d990a2

Please sign in to comment.