Your question is a little vague. Here only the test)test is printed on that line:
\documentclass{article}
\usepackage{lipsum}
\def\foo{}
\def\endfoo{\baz}
\begin{document}
\lipsum[1]
\begin{foo}
abc
\end{foo} test)test
\lipsum
\end{document}
So it really depends on what is causing that warning/error to be printed.
TeX's log output cannot be parsed unambiguously, but there are rules that it follows. When it opens a file, (file.tex is printed in the console; when that file is closed, a matching ) is printed. Pages written out are indicated by [1]...[2]...etc. Any heuristic you write to follow these rules must accept the fact that unmatched parentheses and brackets could appear in the output.
An alternative occurs to me. You can use the currfile and filehook package to print out unambiguous markers for file open/close and use this information instead. For example:
\RequirePackage{filehook,currfile}
\makeatletter
\def\fileindent{}
\def\pushindent{%
\expandafter\def
\expandafter\fileindent
\expandafter{\fileindent\space\space}%
}
\def\popindent{%
\edef\@tempa{%
\noexpand\expandafter\def
\noexpand\expandafter\noexpand\fileindent
\noexpand\expandafter{%
\noexpand\@gobbletwo\unexpanded\expandafter{\fileindent}%
}%
}%
\@tempa
}
\makeatother
\AtBeginOfEveryFile{\typeout{\fileindent Begin file \currfilename}\pushindent}
\AtEndOfEveryFile{\popindent\typeout{\fileindent End file \currfilename}}
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document}
Here, each nested file inclusion is indented in the console output (and this is the cause of the messy code up top). For your purposes this isn't necessary, but I find it easier for visual inspection.
test)testthen the compiled pages [1][2] and [3] and then outputs the information about an included file. The ) after [3] is a closing parenthesis, the opening one is before your l.73 message. See logfile. – Herbert Jan 9 '11 at 16:57-file-line-erroroption? Then you'd get the filename at the beginning of the line, which might be easier to parse. – frabjous Jan 9 '11 at 18:12