1469 Commits

Author SHA1 Message Date
Jon Gjengset
25368a341e
Fix errant backtick in WeakDispatch docs
Note: this error is not present on `master`.
2024-02-08 15:53:32 -05:00
Gabriel Goller
0e4a4bef5e
attributes: change order of async and unsafe modifier (#2864)
When using `#[tracing::instrument]` and the `async unsafe` modifiers
the generated function read `unsafe async fn`, which is wrong. Corrected
the order and added a test.

Fixes: #2576

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-01-26 14:14:00 -08:00
David Barsky
c6bedbe272
chore: prepare tracing-appender 0.2.3 release (#2790)
# 0.2.3 (November 13, 2023)

This release contains several new features. It also increases the
minimum supported Rust version (MSRV) to Rust 1.63.0.

## Added

- **rolling**: add option to automatically delete old log files (#2323)
- **non_blocking**: allow worker thread name to be configured (#2365)
- **rolling**: add a builder for constructing `RollingFileAppender`s
  (#2227)
- **rolling**: add `Builder::filename_suffix` parameter (#2225)
- **non_blocking**: remove `Sync` bound from writer for `NonBlocking`
  (#2607)
- **non_blocking**: name spawned threads (#2219)

## Fixed

- Fixed several documentation typos and issues (#2689, #2375)

## Changed

- Increased minimum supported Rust version (MSRV) to 1.63.0+ (#2793)
- Updated minimum `tracing-subscriber` version to
  [0.3.18][subscriber-v0.3.18] (#2790)

[subscriber-v0.3.18]:
    https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.18
tracing-appender-0.2.3
2023-11-13 19:06:46 +00:00
David Barsky
8b7a1dde69
chore: prepare tracing-subscriber 0.3.18 release (#2789)
# 0.3.18 (November 13, 2023)

This release of `tracing-subscriber` adds support for the [`NO_COLOR`] environment
variable (an informal standard to disable emitting ANSI color escape codes) in
`fmt::Layer`, reintroduces support for the [`chrono`] crate, and increases the
minimum supported Rust version (MSRV) to Rust 1.63.0.

It also introduces several minor API improvements.

### Added

- **chrono**: Add [`chrono`] implementations of `FormatTime` ([#2690])
- **subscriber**: Add support for the [`NO_COLOR`] environment variable in
`fmt::Layer` ([#2647])
- **fmt**: make `format::Writer::new()` public ([#2680])
- **filter**: Implement `layer::Filter` for `Option<Filter>` ([#2407])

### Changed

- **log**: bump version of `tracing-log` to 0.2 ([#2772])
- Increased minimum supported Rust version (MSRV) to 1.63.0+.

[`chrono`]: https://github.com/chronotope/chrono
[`NO_COLOR`]: https://no-color.org/
[#2690]: https://github.com/tokio-rs/tracing/pull/2690
[#2647]: https://github.com/tokio-rs/tracing/pull/2647
[#2680]: https://github.com/tokio-rs/tracing/pull/2680
[#2407]: https://github.com/tokio-rs/tracing/pull/2407
[#2772]: https://github.com/tokio-rs/tracing/pull/2772

Thanks to @shayne-fletcher, @dmlary, @kaifastromai, and @jsgf for contributing!
tracing-subscriber-0.3.18
2023-11-13 09:06:05 -08:00
David Barsky
befb4de073
chore: fix ahash-caused build breakage (#2792)
This branch _should_ fix the CI issues caused by https://github.com/tkaitchuck/aHash/issues/163.

(We can't move to 0.8.5 for MSRV reasons.)

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-11-07 21:48:45 +00:00
David Barsky
1dc1e6a302 chore: bump ahash to 0.7.7 (#2794) 2023-11-07 13:37:19 -08:00
David Barsky
abb23931ef chore: backport CI improvements (#2238) 2023-11-07 13:37:19 -08:00
David Barsky
c6abc10c3a chore: bump MSRV to 1.63 (#2793) 2023-11-07 13:37:19 -08:00
Gabriel Goller
4529182e60 attributes: added missing RecordTypes for instrument (#2781)
When using a function annotated with `#[instrument]` it parses the
parameters of the function and records them either using `Value` or
using `std::fmt::Debug`. There were a few types that implement `Value`
but were missing the RecordTypes array. Added them + a unit test for a
single one.

Fixed: #2775
2023-11-07 13:37:19 -08:00
Nathaniel Cook
7b594354cf subcriber: update docs for EnvFilter Builder (#2782)
The `from_env` and `try_from_env` methods on the builder had the same documentation. This change updates their docs to correctly describe their difference in behavior.


## Motivation

Make the docs more clear, so that users need not look at the source to understand the difference between these two functions.

## Solution

Updated the docs

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-11-07 13:37:19 -08:00
Gabriel Goller
119f91a85c tracing: removed core imports in macros (#2762)
When a user has a crate named `core`, it can cause issues
because our crates import from `::core::*`. Now we are
importing from `$crate::__macro_support::*` and there will
be no more name clashes.
2023-11-07 13:37:19 -08:00
Søren Mortensen
346d6e6456 core: fix incorrect (incorrectly updated) docs for LevelFilter (#2767)
These docs were updated (in response to #1669), but the "or equal to"
phrase should have been moved to the other case.

Fixes: #1993

## Motivation

When these docs were updated in response to #1669, they were updated
incompletely (a level that is equal to a filter is _enabled_, not
_disabled_) and therefore remained incorrect.

## Solution

The docs were updated, moving the "or equal to" phrase to the other
case.
2023-11-07 13:37:19 -08:00
AnthonyMikh
8cdc9da202 appender: remove Sync bound from writer for NonBlocking (#2607)
## Motivation

`NonBlocking` from `tracing-appender` wraps a writer and requires that
writer to implement `Sync` (among other bounds). However it is not clear
why this bound is necessary in first place: this writer is sent to a
dedicated thread and never used directly concurrently.

#1934 demonstrates that it is a real problem for some people. Also at my
current work we hit this issue as well when a third-party writer did not
implement `Sync`. Our workaround was to wrap that writer in our own type
and manually implement `Send` and `Sync` for it. Needless to say that it
is more a hack than a proper solution.

## Solution

Remove `Sync` bound in relevant places. Yep, that simple. Probably
having it in first place was just an oversight.

Closes #1934
2023-11-07 13:37:19 -08:00
Benoît Burnichon
40f757da05 subscriber: update documentation link to latest (#2434)
Currently, link points to an outdated version.

Make the link point to latest released version
2023-11-07 13:37:19 -08:00
Gabriel Goller
f622a1e83e
docs: fix backporting error in attributes (#2780)
There was an error when backporting #1378 (here: #1418) and a trailing
dot (.) was forgotten (which was breaking the link). Fixed also the link to
`std::fmt::Debug`.
2023-10-30 09:55:12 -04:00
David Barsky
4161d8137d
chore: prepare tracing-log 0.2.0 (#2772)
# 0.2.0 (October 24th, 2023)

This release contains two breaking changes: the removal of the `env_logger`
and `trace_logger` features. Below are the suggested migration paths:

- `env_logger`: users should use [`tracing_subscriber::fmt::Subscriber`]
  or [`tracing_subscriber::fmt::Layer`] with the [`Targets`] or
  [`EnvFilter`] filters instead.
- `trace_logger`: users should use the `tracing` crate's
  ["log" feature flag][log-feature] instead. 

### Breaking Changes

- Remove deprecated `env_logger` feature. This removes the dependency
  on the unmaintained `atty` crate, resolving the security advisory
  [GHSA-g98v-hv3f-hcfr]/[RUSTSEC-2021-0145]. ([#2771])  
- Remove deprecated `trace_logger` feature. ([#2771])

[#2771]: https://github.com/tokio-rs/tracing/pull/2771
[`tracing_subscriber::fmt::Subscriber`]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/struct.Subscriber.html
[`tracing_subscriber::fmt::Layer`]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/fmt/struct.Layer.html
[`Targets`]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/filter/targets/struct.Targets.html
[`EnvFilter`]: https://docs.rs/tracing-subscriber/0.3.17/tracing_subscriber/filter/struct.EnvFilter.html
[log-feature]: https://docs.rs/tracing/latest/tracing/#emitting-log-records
[GHSA-g98v-hv3f-hcfr]: https://github.com/advisories/GHSA-g98v-hv3f-hcfr
[RUSTSEC-2021-0145]: https://rustsec.org/advisories/RUSTSEC-2021-0145.html
tracing-log-0.2.0
2023-10-24 18:03:13 +00:00
David Barsky
1c802c7763
log: remove deprecated env_logger and trace_logger APIs (#2771)
Removing the `env_logger` feature in order to address GHSA-g98v-hv3f-hcfr.

In addition, this PR also removes the deprecated `trace_logger` module, in
preparation for an upcoming v0.2.0 of `tracing-log`.

For additional details on the approach, please refer to #2750. Note that this
PR depends on #2770, so this PR will temporarily have more commits 
than intended. 
---------

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-10-24 17:09:21 +00:00
David Barsky
4965c36570
chore: Prepare tracing-log 0.1.4 (#2770)
# 0.1.4 (October 23rd, 2023)

### Changes

- Deprecated `env_logger` feature in favor of 
  `tracing_subscriber::fmt::Subscriber` (#2752)

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
tracing-log-0.1.4
2023-10-23 10:28:50 -07:00
Eliza Weisman
15600a3a67
tracing: prepare to release v0.1.40
# 0.1.40

This release fixes a potential stack use-after-free in the
`Instrument::into_inner` method. Only uses of this method are affected
by this bug.

### Fixed

- Use `mem::ManuallyDrop` instead of `mem::forget` in
  `Instrument::into_inner` (#2765)

[#2765]: https://github.com/tokio-rs/tracing/pull/2765

Thanks to @cramertj and @manishearth for finding and fixing this issue!
tracing-0.1.40
2023-10-18 18:04:51 -07:00
Manish Goregaokar
20a1762b3f
tracing: use ManuallyDrop instead of mem::forget (#2765)
The current code is UB and LLVM could choose to reuse the stack slot causing a UAF.

## Motivation

UB is bad.

## Solution

Don't do that.
2023-10-18 18:00:51 -07:00
David Barsky
4b99457c87
chore: prepare tracing 0.1.39 (#2755)
# 0.1.39 (October 12, 2023)

This release adds several additional features to the `tracing` macros.
In addition, it updates the `tracing-core` dependency to
[v0.1.32][core-0.1.32] and the `tracing-attributes` dependency to
[v0.1.27][attrs-0.1.27].

### Added

- Allow constant field names in macros ([#2617])
- Allow setting event names in macros ([#2699])
- **core**: Allow `ValueSet`s of any length ([#2508])

### Changed

- `tracing-attributes`: updated to [0.1.27][attrs-0.1.27]
- `tracing-core`: updated to [0.1.32][core-0.1.32]
- **attributes**: Bump minimum version of proc-macro2 to 1.0.60
  ([#2732])
-  **attributes**: Generate less dead code for async block return type
   hint ([#2709])

### Fixed

- Use fully qualified names in macros for items exported from std
  prelude ([#2621], [#2757])
- **attributes**: Allow [`clippy::let_with_type_underscore`] in
  macro-generated code ([#2609])
- **attributes**: Allow `unknown_lints` in macro-generated code
  ([#2626])
- **attributes**: Fix a compilation error in `#[instrument]` when the
  `"log"` feature is enabled ([#2599])

### Documented

- Add `axum-insights` to relevant crates. ([#2713])
- Fix link to RAI pattern crate documentation ([#2612])
- Fix docs typos and warnings ([#2581])
- Add `clippy-tracing` to related crates ([#2628])
- Add `tracing-cloudwatch` to related crates ([#2667])
- Fix deadlink to `tracing-etw` repo ([#2602])

[#2617]: https://github.com/tokio-rs/tracing/pull/2617
[#2699]: https://github.com/tokio-rs/tracing/pull/2699
[#2508]: https://github.com/tokio-rs/tracing/pull/2508
[#2621]: https://github.com/tokio-rs/tracing/pull/2621
[#2713]: https://github.com/tokio-rs/tracing/pull/2713
[#2581]: https://github.com/tokio-rs/tracing/pull/2581
[#2628]: https://github.com/tokio-rs/tracing/pull/2628
[#2667]: https://github.com/tokio-rs/tracing/pull/2667
[#2602]: https://github.com/tokio-rs/tracing/pull/2602
[#2626]: https://github.com/tokio-rs/tracing/pull/2626
[#2757]: https://github.com/tokio-rs/tracing/pull/2757
[#2732]: https://github.com/tokio-rs/tracing/pull/2732
[#2709]: https://github.com/tokio-rs/tracing/pull/2709
[#2599]: https://github.com/tokio-rs/tracing/pull/2599
[`let_with_type_underscore`]: http://rust-lang.github.io/rust-clippy/rust-1.70.0/index.html#let_with_type_underscore
[attrs-0.1.27]:
    https://github.com/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.27
[core-0.1.32]:
    https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.32
tracing-0.1.39
2023-10-13 15:26:09 -07:00
Eliza Weisman
b2a5e11e24
tracing: update core to v0.1.31 and attributes to v0.1.27 2023-10-13 15:18:04 -07:00
Gabriel Goller
3825a50c1a
tracing: use full path when calling format_args! (#2757)
When a custom macro "format_args" is defined, macros such as
`tracing::warn`, `tracing::debug`, etc. will fail. Adding the
full path `::core::format_args!` to the calls fixes this.

Fixes: #2721
2023-10-13 15:16:38 -07:00
David Barsky
c4b2a56937
chore: prepare tracing-core 0.1.32 (#2754)
# 0.1.32 (October 13, 2023)

### Documented

- Fix typo in `field` docs (#2611)
- Remove duplicate wording (#2674)

### Changed

- Allow `ValueSet`s of any length (#2508)
tracing-core-0.1.32
2023-10-13 18:14:38 +00:00
David Barsky
2502f19d93
chore: prepare tracing-attributes 0.1.27 (#2756)
# 0.1.27 (October 13, 2023)

### Changed

- Bump minimum version of proc-macro2 to 1.0.60 (#2732)
- Generate less dead code for async block return type hint (#2709)

### Fixed

- Fix a compilation error in `#[instrument]` when the `"log"`
  feature is enabled (#2599)
tracing-attributes-0.1.27
2023-10-13 10:57:26 -07:00
David Barsky
90487620d8
Revert "log: update to env_logger 0.10 to fix GHSA-g98v-hv3f-hcfr (#2740)" (#2750) (#2751)
Backporting #2750, see that PR for details.
2023-10-13 00:29:13 +00:00
David Barsky
6ba5af2ce2
docs: remove mention of Registration on v0.1.x (#2753)
This type does not exist on v0.1.x
2023-10-13 00:12:54 +00:00
David Barsky
11aac9a07c
log: deprecate env_logger in favor of tracing_subscriber::fmt::Subscriber (#2752) 2023-10-12 16:58:25 -07:00
Eliza Weisman
2f27752a99
chore: remove env_logger from hyper example
Currently, the `hyper_echo` example uses the `tracing-log` env logger
support for some weird reason. I believe this is due to Hyper previously
using `log` rather than `tracing`. However, `hyper` now emits native
`tracing` diagnostics, so all the `env_logger` nonsense can just be
removed from the example.

This branch does that.

; Conflicts:
;	examples/Cargo.toml
;	examples/examples/hyper-echo.rs
2023-10-12 12:19:17 -07:00
Toby Murray
f96846d78a
attributes: fix typo "overriden" => "overridden" (#2719)
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
; Conflicts:
;	tracing-attributes/src/lib.rs
2023-10-12 12:08:20 -07:00
Kaifas
71b5b2c579
subscriber: make format::Writer::new() public (#2680)
## Motivation

As seen here #2512 and #2223. Previously pr'ed here #2525, but no progress has
been made there for quite some. I have applied the suggested changes. Not sure
the formatting of the doc is sufficient or otherwise correct

## Solution

Make the `format::Writer::new()` function public. I don't see any obvious
trade-offs, but I am not familiar with the larger direction of
tracing/subscriber, so I may be wrong.

Closes  #2512
Closes #2223

Co-authored-by: Cephas Storm <cephas.storm@borisfx.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-10-12 12:07:47 -07:00
Eliza Weisman
f8c000202a
attributes: fix clippy warning in attributes tests (#2742)
Clippy doesn't like the redefinition of a binding with itself. I don't
think this was necessary for the bug we were reproducing here (as the
error test doesn't do this), so I removed it.
2023-10-12 12:07:38 -07:00
Eliza Weisman
60b2dc3466
journald: fix clippy unwrap_or_default warning (#2742)
The latest Clippy emits warnings for uses of `unwrap_or_else` with
functions that return a type's `Default::default` value, such as
`.unwrap_or_else(String::new)`. Clippy would prefer us to use
`unwrap_or_default` instead, which does the same thing.

This commit fixes the lint. Personally, I don't really care about this,
but it makes the warning go away...
2023-10-12 12:07:26 -07:00
Max Burke
e1a384648a
log: update to env_logger 0.10 to fix GHSA-g98v-hv3f-hcfr (#2740)
The package `atty`, a dependent of `env_logger` < 0.10, has a RUSTSEC advisory
raised against it (GHSA-g98v-hv3f-hcfr). This branch updates `env_logger` to
0.10 to fix this issue.
2023-10-12 12:02:11 -07:00
David Barsky
7f0cc09d0b docs: remove usage of 0.2 terminology (#2728) 2023-10-01 10:46:02 -07:00
Jeremy Fitzhardinge
af66aed83e subscriber: Implement layer::Filter for Option<Filter> (#2407)
It's currently awkward to have an optional per-layer filter.

Implement `Filter<L>` for `Option<F> where F: Filter<L>`, following the example
of `Layer`. A `None` filter passes everything through.

Also, it looks like Filter for Arc/Box doesn't pass through all the methods, so
extend the `filter_impl_body` macro to include them.

This also adds a couple of tests and updates the docs.

---------

Co-authored-by: David Barsky <me@davidbarsky.com>
Co-authored-by: Ryan Johnson <ryantj@fb.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-10-01 10:46:02 -07:00
David Barsky
29f74c52c2 attributes: bump minimum version of proc-macro2 to 1.0.60 (#2732)
As part of landing #2728, I noticed that the `-Zminimal-versions` check fails
due to proc-macro2 1.0.40 referencing a since-removed, nightly-only
feature (`proc_macro_span_shrink`). Since this change doesn't change the MSRV
of `proc-macro2` (or `tracing`, for that matter), this feels like a safe change
to make.
2023-10-01 10:46:02 -07:00
David Barsky
69a5375269 test: remove potentially problematic test (#2728) 2023-10-01 10:46:02 -07:00
Shayne Fletcher
de3f581597 [tracing-subscriber]: add chrono crate implementations of FormatTime (#2690)
Issue https://github.com/tokio-rs/tracing/issues/2080 explains that it's not
possible to soundly use
[`tracing_subscriber::fmt::time::LocalTime`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/time/struct.LocalTime.html)
in a multithreaded context. It proposes adding alternative time formatters that
use the [chrono crate](https://docs.rs/chrono/latest/chrono/) to workaround
which is what this PR offers.

A new source file 'chrono_crate.rs' is added to the 'tracing-subscriber'
package implementing `mod chrono_crate` providing two new tag types `LocalTime`
and `Utc` with associated `time::FormatTime` trait implementations that call
`chrono::Local::now().to_rfc3339()` and `chrono::Utc::now().to_rfc3339()`
respectively. Simple unit-tests of the new functionality accompany the
additions.
---------

Co-authored-by: David Barsky <me@davidbarsky.com>
Co-authored-by: Shayne Fletcher <shaynefletcher@meta.com>
2023-10-01 10:46:02 -07:00
Aaron Roney
223e6c5cc6 docs: add axum-insights to relevant crates. (#2713)
## Motivation

Adding a relevant library to the list of `tracing`-enabled crates.

## Solution

Added to READMEs and documentation.
2023-10-01 10:46:02 -07:00
Joseph Perez
1d8861d29a tracing: allow constant field names in macros (#2617)
I've found myself in the case where I wanted to have customized event field name
for different trait implementations. In fact, these implementations are
completely unrelated (in separate applications), so, in this use case, I find
more readable to have `foo="some_id"` and `bar=16` instead of `resource="foo"
value="some_id"` and `resource=bar value=16`

Because events only accept identifier or literal as field name, this is quite
cumbersome/impossible to do. A simple solution could be to make events accept
constant expression too; in my use case, I could then add a associated constant
to my trait.

This PR proposes a new syntax for using constant field names:
```rust
tracing::debug!({ CONSTANT_EXPR } = "foo");
```
This is the same syntax than constant expression, so it should be quite intuitive.

To avoid constant expression names conflict, internal variables of macro
expansion have been prefixed with `__`, e.g. `__CALLSITE`.

Co-authored-by: Joseph Perez <joseph.perez@numberly.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2023-10-01 10:46:02 -07:00
Finomnis
7666f6c453 journald: allow custom journal fields (#2708)
It's currently not possible to customize how messages will get send to journald.

This became apparent in #2425, where first a specific API got designed, but then
it was decided that users should not get restricted in only a subset of fields,
but should be able to simply choose by themselves what fields get set with what
values.

So in a sense, this is the successor/rework of #2425.

Allow custom fields to be set in tracing-journald.

- [x] How should we deal with fields that also get supplied by other options?
  For example, setting `SYSLOG_IDENTIFIER` here and also setting
  `.with_syslog_identifier()` will send said field twice, potentially with
  differing values. Is that a problem?
    - Answer: No, this is not a problem.

Closes #2425
2023-10-01 10:46:02 -07:00
Aaron Roney
b8180dd886 tracing: allow setting event names in macros (#2699)
## Motivation

The motivation is #1426.  Currently, event names are set to a default
value of `event file:line`, which (1) doesn't allow for customization,
and (2) prevents events from working for some opentelemetry endpoints
(they often use the event name `exception` to designate something like a
panic).

## Solution

Went through the event macros, and added new parameterization that
allows for setting the `name`.  In addition, added some comments, and
reordering, to make life a bit better for the next person that comes
along to edit those macros.  Finally, added tests for the macro
expansion alongside the existing tests with a reasonable amount of
coverage (though, admittedly, more could be added for all of the macro
invocation types

Fixes #1426
2023-10-01 10:46:02 -07:00
Ethan Brierley
1771128aea core: allow ValueSets of any length (#2508)
## Motivation

Fixes: #1566

## Solution

This change removes the maximum of 32 fields limitation using const
generics.

Having this arbitrary restriction in place to prevent stack overflows
feels a little misplaced to me since stack size varies between
environments.
2023-10-01 10:46:02 -07:00
Kornel
df6793f7b7 attributes: generate less dead code for async block return type hint (#2709)
## Motivation

`#[tracing::instrument]` uses `unreachable!()` macro which needlessly
expands to panicking and formatting code. It only needs any `!` type.

## Solution

`loop {}` works just as well for a `!` type, and it crates less work for
the compiler. The code is truly unreachable, so the message would never
be useful. Rust used to be concerned about semantics of empty loops in
LLVM, but this [has been solved](https://reviews.llvm.org/D85393).
2023-10-01 10:46:02 -07:00
Gabi
e6c57d8e81 flame: fix folded formatting (#2710)
## Motivation

The `.folded` format expects a `;`-separated list of the stack function,
optionally followed up by a sample count.

The implementation before this commit added a blank space after each `;`
which made parsers, such as `inferno-flamegraph` mis-interpret the data.

Furthermore, normally one wouldn't expect the filename and line-number
in such stack trace.

## Solution

Remove white-space between `;` for the generated file and remove
filename and line-number by default.
2023-10-01 10:46:02 -07:00
C L Eckhardt
a814b87d10 appender: clarify file appender docs (#2689)
## Motivation

There are a few errors in the file appender docs - this fixes them.

It also wasn't clear/apparent to me that you can create a non-rolling
file appender with the `rolling` module - this calls that out more
clearly.

## Solution

Updates to docs.
2023-10-01 10:46:02 -07:00
Michael Wigard
70107bfad7 attributes: fix instrument with "log" feature (#2599)
## Motivation

The instrument macro currently doesn't work with the "log" crate
feature: #2585

## Solution

Change the generated code to create a span if either
`tracing::if_log_enabled!` or `tracing::level_enabled!`. I'm not sure
how to add a test for this or if this is the best solution.

Fixes #2585
2023-10-01 10:46:02 -07:00
Eliza Weisman
e03a831d05 chore: fix new warnings in Rust 1.72.0 (#2700)
This branch fixes a handful of new warnings which have shown up after
updating to Rust 1.72.0.

This includes:

* `clippy::redundant_closure_call` in macros --- allowed because the
  macro sometimes calls a function that isn't a closure, and the closure
  is just used in the case where it's not a function.
* Unnecessary uses of `#` in raw string literals that don't contain `"`
  characters.
* Dead code warnings with specific feature flag combinations in
  `tracing-subscriber`.

In addition, I've fixed a broken RustDoc link that was making the
Netlify build sad.
2023-10-01 10:46:02 -07:00
David M. Lary
72bbf0fe6d subscriber: support NO_COLOR in fmt::Layer (#2647)
It's necessary at times to be able to disable ANSI color output for
rust utilities using `tracing`.  The informal standard for this is the
`NO_COLOR` environment variable described here: https://no-color.org/

Further details/discussion in #2388

This commit updates `fmt::Layer` to check the `NO_COLOR`
environment variable when determining whether ANSI color output is
enabled by default. As described in the spec, any non-empty value set
for `NO_COLOR` will cause ANSI color support to be disabled by default.

If the user manually overrides ANSI color support, such as by calling
`with_ansi(true)`, this will still enable ANSI colors, even if
`NO_COLOR` is set. The `NO_COLOR` env var only effects the default
behavior.

Fixes #2388
2023-10-01 10:46:02 -07:00