Skip to content

Best way to highlight json logs #2732

Answered by keith-hall
Tony-Sol asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't really possible without editing the syntax definition, which is basically just a YAML file with regex patterns. https://github.com/sharkdp/bat/blob/master/assets/syntaxes/02_Extra/log.sublime-syntax.

Likely you'd want to add a new - match to the main_without_log_level_line context to look for { and embed the JSON syntax and pop at EOL.
You should be able to experiment by copying the log.sublime-syntax file to your bat config folder and following the instructions https://github.com/sharkdp/bat/tree/master#adding-new-syntaxes--language-definitions

If you can share some example log lines, I might be able to spare some time to work on it at some point.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Tony-Sol
Comment options

@keith-hall
Comment options

Answer selected by Tony-Sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants