This is not a direct answer to your question, because I wonder if Vim might already have a more comprehensive solution for your problem.
Vim has support for running a compilation process, opening the compilation output (in the QuickFix List), and jumping to lines where errors were reported.
Option 1
If you use a GNU Makefile, and you are in the same folder, then all you need to do to compile is type:
:make
Option 2
But if you compile in a different way, you should first tell Vim how:
:set makeprg=gcc\ file.c\ -o\ myapp
" Or to avoid escaping those spaces, you can instead do:
:let &makeprg="gcc file.c -o myapp"
And then you can compile using your specified method, by doing:
:make
Option 3
If you don't want to run the compilation from inside Vim, but you still want to open the logfile in the QuickFix List, then do this:
:cfile my_compilation.log
Viewing the errors
The QuickFix List is useful because it can recognise some error log formats, and help you to navigate them. To step forwards or backwards through errors, use:
:cnext
:cprev
To view all the errors, open the QuickFix Window:
:copen
In that window you can jump to source of an error by pressing Enter. To open in a newly split window, hit Ctrl+W Enter.
Further information
For more details on the whole process, see:
:help :make
:help 'makeprg'
:help quickfix
:help errorformat