FUN WITH LINUX

Colorful Postfix-mail.log

10 November 2014

With nice colors logfiles get more readable. I like the postfix-format of “multitail”.  

multitail -CS postfix -f /var/log/mail.log:

If i wanted to edit a mail.log with vim, i always have missed the colours. so i just created a color-scheme for vim:

Vim:

~/.vim/syntax/maillog.vim:

" Vim syntax file
" Language: mail.log files
" Maintainer: Hoti
" Last Change: 2011-09-06
" Filenames: mail.log
" Version: 0.1


if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syntax match maillogDate /^.* \d\{1,2} \d\d:\d\d:\d\d /
syntax match maillogToMail /to=/
syntax match maillogFromMail /from=/
syntax match maillogStatus /status=\a* /
syntax match maillogNoSpam / Passed CLEAN/
syntax match maillogBlockedSpam / Blocked SPAM/
syntax match maillogBlockedRBL /blocked using.*$/


highlight default link maillogDate Comment
highlight default link maillogToMail Constant
highlight default link maillogFromMail Type
highlight default link maillogStatus Statement
highlight default link maillogNoSpam Type
highlight default link maillogBlockedSpam Constant
highlight default link maillogBlockedRBL Constant

let b:current_syntax = "maillog"

we need to edit our ~/.vimrc and add the following line:

autocmd BufRead,BufNewFile mail.log set syntax=maillog

Download full source

[ Linux  vim  Mail  ]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 Unported License.

Copyright 2015-2021 Hoti