feat: add log file support and rendering optimisations#14
Open
neilmartin83 wants to merge 1 commit intomacadmins:mainfrom
Open
feat: add log file support and rendering optimisations#14neilmartin83 wants to merge 1 commit intomacadmins:mainfrom
neilmartin83 wants to merge 1 commit intomacadmins:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds QuickLook preview support for log files (
.log,.out,.err) withheuristic-based syntax highlighting. Since log files have no consistent format,
the tokenizer uses pattern matching to colorize the most common elements that
make logs scannable at a glance.
Also speeds up rendering of large files.
What's highlighted
2025-09-16 06:20:56 +0100,Mar 28 14:05:33, Apache CLFFATAL,CRITICAL:ERROR,ERROR:WARN,WARNING:INFO,INFO:DEBUG,VERBOSE192.168.1.100GET,POST,DELETE200(green),404(orange),500(red)"disk space low"/usr/local/etc/config.yaml512MB,30s,94%Single quotes are intentionally not treated as string delimiters — apostrophes
in natural log text (
JWT's,doesn't) are far too common.Performance
Log files can be large (2MB+), so three optimizations were made:
.log— avoids O(n²) regex scanning overthe entire file by processing each line independently
escapeHTMLrewritten as a single-pass character scan (was 4 chainedreplacingOccurrencescalls, benefiting all formats)renderTokensuses a pre-allocated buffer instead ofmap+joined"⋯ Preview truncated (X of Y lines shown)" notice
Files changed (8 files, +306 −23)
Shared/SyntaxHighlighter.swift—.logformat, tokenizer, perf improvements, truncationPiquePreview/Info.plist— UTI, QLSupportedContentTypes, QLFileExtensionsPiquePreview/PreviewProvider.swift— format name mappingPique/Info.plist— UTI declarationPique/ContentView.swift— Log badgePique/SettingsView.swift— Log in appearance settingsPiqueTests/FileFormatTests.swift— extension mapping + case insensitivityPiqueTests/HighlightIntegrationTests.swift— 15 new testsTests
137 total, 0 failures. New tests cover:
JWT'snot treated as string).LOG)