Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add syntax highlighting and filtering for Nextflow log files#197

Merged
bentsherman merged 11 commits into
mainfrom
syntax-logfiles
May 27, 2026
Merged

Add syntax highlighting and filtering for Nextflow log files#197
bentsherman merged 11 commits into
mainfrom
syntax-logfiles

Conversation

@ewels

@ewels ewels commented May 20, 2026

Copy link
Copy Markdown
Member

Something I've been wanting to do for ages: nicer rendering of .nextflow.log files. Context and previous efforts:

Looks like this:

CleanShot 2026-05-20 at 18 26 58@2x
  1. Opens in "read only" mode with a lock, not editable by default
  2. Log lines are coloured using TextMate regular expressions
  3. DEBUG and TRACE lines are at 30% opacity
  4. INFO and above are 100% opacity

Warning and error blocks have background colour:

CleanShot 2026-05-20 at 18 28 53@2x

Buttons at top and bottom toolbar open a menu:

CleanShot 2026-05-20 at 18 29 22@2x CleanShot 2026-05-20 at 18 29 53@2x

Allows you to hide log messages of various levels, turn on / off the ANSI code removal, and save to settings. Also to open in "regular mode" (editable, but disables ansi stripping and hiding log lines).

Need to run now, will try to do a video walkthrough ASAP.

Details
  • Adds a nextflow-log language for .nextflow.log* files with a TextMate grammar (timestamps, threads, levels, loggers, work-dir hashes, process names, paths, key=value, exception lines, stack traces) and decorations that dim DEBUG/TRACE entries and paint whole-line backgrounds + overview-ruler marks on WARN/ERROR.
  • Filtering hides whole levels by swapping the editor to a read-only virtual document (nextflow-log-filtered: FileSystemProvider): the hidden lines are genuinely removed from view — no folds, no empty lines, no gutter remnants. ANSI escape codes are stripped from this view by default.
  • Filter state (hidden levels, ANSI strip, raw view) is per-file and ephemeral — lives in memory, cleared when the file's last tab closes. Two explicit Save to workspace settings / Save to global settings items in the picker write the current state as the new default for future opens (and omit any key whose value matches the package.json default, keeping settings.json clean).

ewels and others added 4 commits May 20, 2026 13:53
Adds a nextflow-log language for .nextflow.log* files with a TextMate
grammar that highlights timestamps, threads, levels, loggers, work-dir
hashes, process names, paths, key=value pairs, exception lines, and
stack traces. DEBUG/TRACE entries are dimmed via an opacity decoration
and the level token is forced to a neutral gray; ERROR/WARN entries get
whole-line backgrounds plus overview-ruler marks.

Adds a per-level filter that swaps the editor to a read-only virtual
document (registered FileSystemProvider on the nextflow-log-filtered
scheme) containing only the visible lines — hidden lines are genuinely
removed from view rather than folded or blanked. The filter UI surfaces
through a CodeLens at the top of the file, a status-bar item with a
QuickPick, and per-level editor-title icons.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Replaces the prior fold-based level filter with a read-only virtual
document (nextflow-log-filtered: FileSystemProvider) that .nextflow.log
files swap into on open. Hidden levels are genuinely removed from the
view; ANSI escape codes are stripped by default; the file on disk is
never modified.

Filter state is now per-file and lives in memory only — toggling levels,
ANSI stripping, or the raw-view mode is ephemeral and resets when the
file's last tab is closed. Two explicit Save items in the picker write
the current state to workspace or global settings (and omit any value
that matches the package.json default, keeping settings.json clean).

Also: dedupe isNextflowLogEditor into constants.ts, parallelize the
visible-editor sync with Promise.all, hoist the TextEncoder allocation,
short-circuit the state-cleanup pass when no log files are tracked, and
replace the withActiveState callback wrapper with a direct accessor for
consistency across toggle handlers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ewels ewels changed the title Add syntax highlighting + cleaned view for .nextflow.log files Add syntax highlighting + cleaned view for .nextflow.log files May 20, 2026
@bentsherman bentsherman linked an issue May 20, 2026 that may be closed by this pull request
@bentsherman bentsherman self-requested a review May 20, 2026 16:39
@ewels ewels linked an issue May 20, 2026 that may be closed by this pull request
@ewels

ewels commented May 20, 2026

Copy link
Copy Markdown
Member Author

Slightly hasty video of it in action:

vscode_nextflow_log_v0.mp4

ewels and others added 2 commits May 20, 2026 22:39
Uses the Nextflow arc shapes (top and bottom pairs) as the frame with
"LOG" set in JetBrains Mono between them, all in Nextflow green. Wired
through the nextflow-log language entry in package.json.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rnings

Adds a FileDecorationProvider that scans .nextflow.log* files for
ERROR and WARN header lines and surfaces a small badge in the file
explorer: red "E" for any errors, yellow "W" for warnings-only. The
tooltip carries the full count.

Scans are cached by URI + mtime and invalidated by a FileSystemWatcher
on the same glob, so live-tailed logs update as they grow. Failed
reads are not cached so a transient permission error doesn't pin a
stale "no badge" state.

The file pattern (glob + path regex) is centralized in constants.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ewels

ewels commented May 20, 2026

Copy link
Copy Markdown
Member Author

Couple of updates:

  • Nextflow log files now have their own icon, so as not to clash with regular .nf files
  • File explorer highlighting shows which have error / warning log lines within them
CleanShot 2026-05-20 at 23 03 11@2x

Signed-off-by: Ben Sherman <[email protected]>
Signed-off-by: Ben Sherman <[email protected]>

@bentsherman bentsherman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the log icon -- it feels a bit overkill, and the default log icon seems fine

I also removed some commands from the command palette that were already covered by the code lens

One issue -- the "Show raw file view" doesn't seem to work. When I try to disable the filtered view, nothing changes

@ewels

ewels commented May 26, 2026

Copy link
Copy Markdown
Member Author

I also removed some commands from the command palette that were already covered by the code lens

Can you elaborate? They are one and the same thing, no?

@ewels

ewels commented May 26, 2026

Copy link
Copy Markdown
Member Author

One issue -- the "Show raw file view" doesn't seem to work. When I try to disable the filtered view, nothing changes

If you're showing all the log lines, that's expected. You'll see a visual change if you were previously hiding lines.

You should also see the file tab change. By default it loads with a little lock icon and you can't edit the file. After selecting that option it goes to normal and you can (but the command menu can't filter lines etc in that mode).

@bentsherman

Copy link
Copy Markdown
Member

I see, so the "raw file" view only disables the filtering and lock but not the opacity

In that case, I think we should restructure some of the settings to make this relationship clear:

  • nextflow.log.filter.enabled (default true): Enable filtering by log level. Logs are read-only when filtered. (replaces nextflow.log.showRawFile)

  • nextflow.log.filter.hiddenLevels (same as before)

  • nextflow.log.filter.stripAnsi (same as before)

@ewels

ewels commented May 26, 2026

Copy link
Copy Markdown
Member Author

I also removed some commands from the command palette that were already covered by the code lens

Can you elaborate? They are one and the same thing, no?

Just re-read this - I misunderstood on the first pass. Totally fine to remove from the command palette. I confess that I had totally forgotten that this PR added any commands there 👀

@ewels

ewels commented May 26, 2026

Copy link
Copy Markdown
Member Author

@bentsherman I updated the setting name as suggested.

For now the codelens menu reads the same (Open as editable file), are you happy with that?

CleanShot 2026-05-26 at 22 32 52@2x

Comment thread .gitignore Outdated
@ewels

ewels commented May 26, 2026

Copy link
Copy Markdown
Member Author

Ok I added a custom log icon back again, but a much less offensive one hopefully - basically the same as the default "no icon" icon, but in Nextflow green.

I also switched out the Nextflow icon to use SVG instead of PNG, and made it a smidge smaller:

CleanShot 2026-05-26 at 23 19 14@2x

The alignment is a little off to the left, but apparently this is a padding issue in VS Code which is effectively impossible to solve.

Signed-off-by: Ben Sherman <[email protected]>
@bentsherman bentsherman changed the title Add syntax highlighting + cleaned view for .nextflow.log files Add syntax highlighting and filtering for Nextflow log files May 27, 2026
@bentsherman bentsherman merged commit 02d3633 into main May 27, 2026
@bentsherman bentsherman deleted the syntax-logfiles branch May 27, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax highlighting for .nextflow.log files

2 participants