Skip to content

Commit 2f6679a

Browse files
authored
Print sources when DEBUG=* is set (#17952)
This PR improves the debug logging by also adding the provided `@source` to the log file. It will also print the optimized sources (the ones we expand and mark as `Auto` or `Pattern`). In the logs, this will look like this: ``` 2025-05-09T11:03:32.906478Z INFO tailwindcss_oxide::scanner: Provided sources: 2025-05-09T11:03:32.906544Z INFO tailwindcss_oxide::scanner: Source: PublicSourceEntry { base: "/Users/robin/github.com/RobinMalfait/spreadsheet", pattern: "**/*", negated: false } 2025-05-09T11:03:32.906589Z INFO tailwindcss_oxide::scanner: Optimized sources: 2025-05-09T11:03:32.906595Z INFO tailwindcss_oxide::scanner: Source: Auto { base: "/Users/robin/github.com/RobinMalfait/spreadsheet" } ``` Or if you have more sources: ``` 2025-05-09T11:06:54.767546Z INFO tailwindcss_oxide::scanner: Provided sources: 2025-05-09T11:06:54.767660Z INFO tailwindcss_oxide::scanner: Source: PublicSourceEntry { base: "/Users/robin/github.com/RobinMalfait/spreadsheet", pattern: "**/*", negated: false } 2025-05-09T11:06:54.767987Z INFO tailwindcss_oxide::scanner: Source: PublicSourceEntry { base: "/Users/robin/github.com/RobinMalfait/spreadsheet/app", pattern: "./routes/*.{jsx,tsx}", negated: false } 2025-05-09T11:06:54.767992Z INFO tailwindcss_oxide::scanner: Source: PublicSourceEntry { base: "/Users/robin/github.com/RobinMalfait/spreadsheet/app", pattern: "./utils/*.ts", negated: false } 2025-05-09T11:06:54.768450Z INFO tailwindcss_oxide::scanner: Optimized sources: 2025-05-09T11:06:54.768455Z INFO tailwindcss_oxide::scanner: Source: Auto { base: "/Users/robin/github.com/RobinMalfait/spreadsheet" } 2025-05-09T11:06:54.768459Z INFO tailwindcss_oxide::scanner: Source: Pattern { base: "/Users/robin/github.com/RobinMalfait/spreadsheet/app/routes", pattern: "*.jsx" } 2025-05-09T11:06:54.768462Z INFO tailwindcss_oxide::scanner: Source: Pattern { base: "/Users/robin/github.com/RobinMalfait/spreadsheet/app/routes", pattern: "*.tsx" } 2025-05-09T11:06:54.768466Z INFO tailwindcss_oxide::scanner: Source: Pattern { base: "/Users/robin/github.com/RobinMalfait/spreadsheet/app/utils", pattern: "*.ts" } ```
1 parent ae57d26 commit 2f6679a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Upgrade: Automatically convert candidates with arbitrary values to their utilities ([#17831](https://github.com/tailwindlabs/tailwindcss/pull/17831), [#17854](https://github.com/tailwindlabs/tailwindcss/pull/17854))
13-
- Write to log file when using `DEBUG=*` ([#17906](https://github.com/tailwindlabs/tailwindcss/pull/17906))
13+
- Write to log file when using `DEBUG=*` ([#17906](https://github.com/tailwindlabs/tailwindcss/pull/17906), [#17952](https://github.com/tailwindlabs/tailwindcss/pull/17952))
1414
- Add support for source maps in development ([#17775](https://github.com/tailwindlabs/tailwindcss/pull/17775))
1515

1616
### Fixed

crates/oxide/src/scanner/mod.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,24 @@ pub struct Scanner {
153153

154154
impl Scanner {
155155
pub fn new(sources: Vec<PublicSourceEntry>) -> Self {
156+
init_tracing();
157+
158+
if *SHOULD_TRACE {
159+
event!(tracing::Level::INFO, "Provided sources:");
160+
for source in &sources {
161+
event!(tracing::Level::INFO, "Source: {:?}", source);
162+
}
163+
}
164+
156165
let sources = Sources::new(public_source_entries_to_private_source_entries(sources));
157166

167+
if *SHOULD_TRACE {
168+
event!(tracing::Level::INFO, "Optimized sources:");
169+
for source in sources.iter() {
170+
event!(tracing::Level::INFO, "Source: {:?}", source);
171+
}
172+
}
173+
158174
Self {
159175
sources: sources.clone(),
160176
walker: create_walker(sources),
@@ -163,7 +179,6 @@ impl Scanner {
163179
}
164180

165181
pub fn scan(&mut self) -> Vec<String> {
166-
init_tracing();
167182
self.scan_sources();
168183

169184
// TODO: performance improvement, bail early if we don't have any changed content

0 commit comments

Comments
 (0)