11" Vim syntax file
22" Language: Generic log file
3- " Maintainer: Mao-Yining <https://github.com/ mao- yining>
3+ " Maintainer: Mao-Yining <mao. yining@outlook.com >
44" Former Maintainer: MTDL9 <https://github.com/MTDL9>
55" Latest Revision: 2025-10-31
66
1010
1111syntax case ignore
1212
13- " Operators
13+ " Symbols / special characters
1414" ---------------------------------------------------------------------------
15- syn match logOperator display ' [;,\?\:\.\< =\>\~\/\@\! $\% &\+\-\|\^ (){}\* #]'
16- syn match logBrackets display ' [][]'
15+ syn match logSymbol display ' [!@#$%^&*;:?]'
1716
1817" For Visual Separator and Apache CLF
1918" ---------------------------------------------------------------------------
@@ -22,10 +21,10 @@ syn match logSeparator display '- - '
2221
2322" Strings
2423" ------------------------------
25- syn region LogString start =/ "/ end =/ "/ end =/ $/ skip =/ \\ ./ contains =logJavaError
26- syn region LogString start =/ `/ end =/ `/ end =/ $/ skip =/ \\ ./ contains =logJavaError
24+ syn region logString start =/ "/ end =/ "/ end =/ $/ skip =/ \\ ./ contains =logJavaError
25+ syn region logString start =/ `/ end =/ `/ end =/ $/ skip =/ \\ ./ contains =logJavaError
2726" Quoted strings, but no match on quotes like `don't`, possessive `s'` and `'s`
28- syn region LogString start =/ \( s\)\@ <!'\( s \| t \)\@ !/ end =/ '/ end =/ $/ skip =/ \\ ./ contains =logJavaError
27+ syn region logString start =/ \( s\)\@ <!'\( s \| t \)\@ !/ end =/ '/ end =/ $/ skip =/ \\ ./ contains =logJavaError
2928
3029" Numbers
3130" ---------------------------------------------------------------------------
@@ -40,7 +39,7 @@ syn match logNumberHex display '\<0[xX]\x\+\>'
4039syn match logNumberHex display ' \<\x\{ 4,}\> '
4140
4241" Numbers in Hardware Description Languages e.g. Verilog
43- " These must be placed after LogString to ensure they take precedence
42+ " These must be placed after logString to ensure they take precedence
4443syn match logNumber display ' \' d\d\+\> '
4544syn match logNumberBin display ' \' b[01]\+\> '
4645syn match logNumberOct display ' \' o\o\+\> '
@@ -68,9 +67,9 @@ syn match logDate display '\<\d\{1,2}[- ]\a\{3}[- ]\d\{4}\>'
6867" Weekday string
6968syn keyword logDate Mon Tue Wed Thu Fri Sat Sun
7069" Matches 12:09:38 or 00:03:38.129Z or 01:32:12.102938 +0700 or 01:32:12.1234567890 or 21:14:18+11:00
71- syn match logTime display ' \d\{ 2}:\d\{ 2}:\d\{ 2}\(\.\d\{ 2,9}\)\?\(\s\? [-+]\(\d\{ 1,2\} :\d\{ 2\}\|\d\{ 2,4}\)\| Z\)\?\> ' nextgroup =logTimeZone,logSysColumns skipwhite
70+ syn match logTime display ' \d\{ 2}:\d\{ 2}:\d\{ 2}\(\.\d\{ 2,9}\)\?\(\s\? [-+]\(\d\{ 1,2\} :\d\{ 2\}\|\d\{ 2,4}\)\| Z\)\?\> ' nextgroup =logTimeZone,logSysColumn skipwhite
7271" Time zone e.g. Z, +08:00, PST
73- syn match logTimeZone display ' Z\| [+-]\d\{ 2}:\d\{ 2}\|\a\{ 3}\> ' contained skipwhite nextgroup =logSysColumns
72+ syn match logTimeZone display ' Z\| [+-]\d\{ 2}:\d\{ 2}\|\a\{ 3}\> ' contained skipwhite nextgroup =logSysColumn
7473" Matches time durations like 1ms or 1y 2d 23ns 3.14s 1.2e4s 3E+20h
7574syn match logDuration display ' \(\(\(\d\+ d\)\?\d\+ h\)\?\d\+ m\)\?\d\+\(\.\d\+\)\? [mun]\? s\> '
7675
@@ -95,61 +94,61 @@ syn match logFilePath display '\(^\|\s\|=\)\zs\\\\\f\+\ze'
9594
9695" Java Errors
9796" ---------------------------------------------------------------------------
98- syn match logJavaError ' \% (\% (Error\| Exception\) :\s *\)\z s\w .\{ -}\z e\(\\ n\| $\) ' contained
97+ syn match logJavaError ' \% (\% (Error\| Exception\) :\s *\)\z s\w .\{ -}\z e\(\\ n\| $\) ' contained
9998
10099" Syslog Columns
101100" ---------------------------------------------------------------------------
102101" Syslog hostname, program and process number columns
103- syn match logSysColumns ' \w\(\w\|\.\| -\)\+ \(\w\|\.\| -\)\+\(\[\d\+\]\)\? :' contains =logOperator, @logLvs,LogSysProcess contained
104- syn match logSysProcess ' \(\w\|\.\| -\)\+\(\[\d\+\]\)\? :' contains =logOperator, logNumber,logBrackets contained
102+ syn match logSysColumn ' \w\(\w\|\.\| -\)\+ \(\w\|\.\| -\)\+\(\[\d\+\]\)\? :' contained contains =@logLvs,logSysProcess
103+ syn match logSysProcess ' \(\w\|\.\| -\)\+\(\[\d\+\]\)\? :' contained contains =logNumber
105104
106105" XML Tags
107106" ---------------------------------------------------------------------------
108107" Simplified matches, not accurate with the spec to avoid false positives
109108syn match logXmlHeader / <?\(\w\| -\)\+\(\s\+\w\+\( ="[^"]*"\| ='[^']*'\)\?\) *?>/ contains =logString,logXmlAttribute,logXmlNamespace
110109syn match logXmlDoctype / <!DOCTYPE[^>]*>/ contains =logString,logXmlAttribute,logXmlNamespace
111110syn match logXmlTag / <\/\?\(\(\w\| -\)\+ :\)\?\(\w\| -\)\+\(\(\n\|\s\)\+\(\(\w\| -\)\+ :\)\?\(\w\| -\)\+\( ="[^"]*"\| ='[^']*'\)\?\) *\s *\/\? >/ contains =logString,logXmlAttribute,logXmlNamespace
112- syn match logXmlAttribute contained " \w\+ =" contains = logOperator
113- syn match logXmlAttribute contained " \(\n\|\s\)\(\(\w\| -\)\+ :\)\?\(\w\| -\)\+\( =\)\? " contains =logXmlNamespace,logOperator
114- syn match logXmlNamespace contained " \(\w\| -\)\+ :" contains = logOperator
111+ syn match logXmlAttribute contained " \w\+ ="
112+ syn match logXmlAttribute contained " \(\n\|\s\)\(\(\w\| -\)\+ :\)\?\(\w\| -\)\+\( =\)\? " contains =logXmlNamespace
113+ syn match logXmlNamespace contained " \(\w\| -\)\+ :"
115114syn region logXmlComment start =/ <!--/ end =/ -->/
116115syn match logXmlCData / <!\[ CDATA\[ .*\]\] >/
117116syn match logXmlEntity / &#\?\w\+ ;/
118117
119118" Levels
120119" ---------------------------------------------------------------------------
121- syn keyword logLvFatal FATAL Fatal fatal
122- syn keyword logLvEmergency EMERG[ENCY] Emerg[ency] emerg[ency]
123- syn keyword logLvAlert ALERT Alert alert
124- syn keyword logLvCritical CRIT[ICAL] Crit[ical] crit[ical]
125- syn keyword logLvError E ERR[ORS] Err[ors] err[ors]
126- syn keyword logLvFail F FAIL[ED] Fail[ed] fail[ed] FAILURE Failure failure
127- syn keyword logLvFault FAULT Fault fault
128- syn keyword logLvNack NACK Nack nack NAK Nak nak
129- syn keyword logLvWarning W WARN[ING] Warn[ing] warn[ing]
130- syn keyword logLvBad BAD Bad bad
131- syn keyword logLvNotice NOTICE Notice notice
132- syn keyword logLvInfo I INFO Info info
133- syn keyword logLvDebug D DEBUG Debug debug DBG Dbg dbg
134- syn keyword logLvTrace TRACE Trace trace
135- syn keyword logLvVerbose V VERBOSE Verbose verbose
136- syn keyword logLvPass PASS[ED] Pass[ed] pass[ed]
137- syn keyword logLvSuccess SUCCEED[ED] Succeed[ed] succeed[ed] SUCCESS Success success
120+ syn keyword logLvFatal FATAL
121+ syn keyword logLvEmergency EMERG[ENCY]
122+ syn keyword logLvAlert ALERT
123+ syn keyword logLvCritical CRIT[ICAL]
124+ syn keyword logLvError E ERR[ORS]
125+ syn keyword logLvFail F FAIL[ED] FAILURE
126+ syn keyword logLvFault FAULT
127+ syn keyword logLvNack NACK NAK
128+ syn keyword logLvWarning W WARN[ING]
129+ syn keyword logLvBad BAD
130+ syn keyword logLvNotice NOTICE
131+ syn keyword logLvInfo I INFO
132+ syn keyword logLvDebug D DEBUG
133+ syn keyword logLvTrace TRACE Trace
134+ syn keyword logLvVerbose V VERBOSE
135+ syn keyword logLvPass PASS[ED]
136+ syn keyword logLvSuccess SUCCEED[ED] SUCCESS
138137
139138" Composite log levels e.g. *_INFO
140- syn match logLvFatal display ' \<\u\+ _FATAL\> '
141- syn match logLvEmergency display ' \<\u\+ _EMERG\( ENCY\)\?\> '
142- syn match logLvAlert display ' \<\u\+ _ALERT\> '
143- syn match logLvCritical display ' \<\u\+ _CRIT\( ICAL\)\?\> '
144- syn match logLvError display ' \<\u\+ _ERR\( OR\)\?\> '
145- syn match logLvFail display ' \<\u\+ _FAIL\( URE\)\?\> '
146- syn match logLvWarning display ' \<\u\+ _WARN\( ING\)\?\> '
147- syn match logLvNotice display ' \<\u\+ _NOTICE\> '
148- syn match logLvInfo display ' \<\u\+ _INFO\> '
149- syn match logLvDebug display ' \<\u\+ _DEBUG\> '
150- syn match logLvTrace display ' \<\u\+ _TRACE\> '
151-
152- syn cluster logLvs contains =LogLvFatal,LogLvEmergency,LogLvAlert,LogLvCritical,LogLvError,LogLvFail,LogLvFault,LogLvNack,LogLvWarning,LogLvBad,LogLvNotice,LogLvInfo,LogLvDebug,LogLvTrace,LogLvVerbose,LogLvPass,LogLvSuccess
139+ syn match logLvFatal display ' \<\u\+ _FATAL\> '
140+ syn match logLvEmergency display ' \<\u\+ _EMERG\( ENCY\)\?\> '
141+ syn match logLvAlert display ' \<\u\+ _ALERT\> '
142+ syn match logLvCritical display ' \<\u\+ _CRIT\( ICAL\)\?\> '
143+ syn match logLvError display ' \<\u\+ _ERR\( OR\)\?\> '
144+ syn match logLvFail display ' \<\u\+ _FAIL\( URE\)\?\> '
145+ syn match logLvWarning display ' \<\u\+ _WARN\( ING\)\?\> '
146+ syn match logLvNotice display ' \<\u\+ _NOTICE\> '
147+ syn match logLvInfo display ' \<\u\+ _INFO\> '
148+ syn match logLvDebug display ' \<\u\+ _DEBUG\> '
149+ syn match logLvTrace display ' \<\u\+ _TRACE\> '
150+
151+ syn cluster logLvs contains =logLvFatal,logLvEmergency,logLvAlert,logLvCritical,logLvError,logLvFail,logLvFault,logLvNack,logLvWarning,logLvBad,logLvNotice,logLvInfo,logLvDebug,logLvTrace,logLvVerbose,logLvPass,logLvSuccess
153152
154153" Highlight links
155154" ---------------------------------------------------------------------------
@@ -179,7 +178,7 @@ hi def link logFilePath Structure
179178
180179hi def link logJavaError ErrorMsg
181180
182- hi def link logSysColumns Statement
181+ hi def link logSysColumn Statement
183182hi def link logSysProcess Function
184183
185184hi def link logXmlHeader Function
@@ -191,32 +190,31 @@ hi def link logXmlComment Comment
191190hi def link logXmlCData String
192191hi def link logXmlEntity Special
193192
194- hi def link logOperator Special
195- hi def link logBrackets Special
193+ hi def link logSymbol Delimiter
196194hi def link logSeparator Comment
197195
198- hi def link LogLvFatal ErrorMsg
199- hi def link LogLvEmergency ErrorMsg
200- hi def link LogLvAlert ErrorMsg
201- hi def link LogLvCritical ErrorMsg
202- hi def link LogLvError ErrorMsg
203- hi def link LogLvFail ErrorMsg
204- hi def link LogLvFault ErrorMsg
205- hi def link LogLvNack ErrorMsg
206- hi def link LogLvWarning WarningMsg
207- hi def link LogLvBad WarningMsg
208- hi def link LogLvNotice Exception
209- hi def link LogLvInfo LogBlue
210- hi def link LogLvDebug Debug
211- hi def link LogLvTrace Special
212- hi def link LogLvVerbose Special
213- hi def link LogLvPass LogGreen
214- hi def link LogLvSuccess LogGreen
196+ hi def link logLvFatal ErrorMsg
197+ hi def link logLvEmergency ErrorMsg
198+ hi def link logLvAlert ErrorMsg
199+ hi def link logLvCritical ErrorMsg
200+ hi def link logLvError ErrorMsg
201+ hi def link logLvFail ErrorMsg
202+ hi def link logLvFault ErrorMsg
203+ hi def link logLvNack ErrorMsg
204+ hi def link logLvWarning WarningMsg
205+ hi def link logLvBad WarningMsg
206+ hi def link logLvNotice Exception
207+ hi def link logLvInfo logBlue
208+ hi def link logLvDebug Debug
209+ hi def link logLvTrace Special
210+ hi def link logLvVerbose Special
211+ hi def link logLvPass logGreen
212+ hi def link logLvSuccess logGreen
215213
216214" Custom highlight group
217215" ------------------------------
218- hi logGreen ctermfg= lightgreen guifg= #a4c672
219- hi logBlue ctermfg= lightblue guifg= # 92 bcfc
216+ hi logGreen ctermfg= LightGreen guifg= LightGreen
217+ hi logBlue ctermfg= LightBlue guifg= LightBlue
220218
221219
222220let b: current_syntax = ' log'
0 commit comments