actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

[Support] : Provided Support to Log the Current Thread name attribute as mentioned in the documentations at https://actix.rs/docs/middleware/

Open Atri10 opened this issue 1 year ago • 0 comments
trafficstars

PR Type: [Supoort]

This PR provides support to log the name of current thread which is handling the request.

PR Checklist

  • [ ] Tests for the changes have been added / updated.
  • [ ] Documentation comments have been added / updated.
  • [ ] A changelog entry has been made for the appropriate packages.
  • [x] Format code with the latest stable rustfmt.
  • [ ] (Team) Label with affected crates and semver status.

Overview

Current behaviour with default Format shown below

r#"%a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T"#

We get Log:

[2024-04-11T17:29:13.432712900Z INFO  actix_web::middleware::logger] 127.0.0.1 "GET /spells HTTP/1.1" 200 285229 "-" "PostmanRuntime/7.37.3" 0.020495

New Behaviour (With custom Format shown below)

wrap(Logger::new(r#"[%P] [%a] ["%r"] [Response = %s] [Size = %b] "%{Referer}i" "%{User-Agent}i" Processed in %Tms."#))

We get Log:

[2024-04-11T17:31:15.122169300Z INFO  actix_web::middleware::logger] [actix-rt|system:0|arbiter:0] [127.0.0.1] ["GET /spells HTTP/1.1"] [Response = 200] [Size = 285229] "-" "PostmanRuntime/7.37.3" Processed in 0.020377ms.

Atri10 avatar Apr 11 '24 17:04 Atri10