Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ library for log parsing [closed]

Is there any C++ library specifically for log parsing (helping recognize multiline events)? Like MergeLog for Apache logs or libcurl for web parsing?

like image 433
Joao Figueiredo Avatar asked Jan 06 '11 12:01

Joao Figueiredo


2 Answers

Unless you stumble upon a suitable library, my advice would be to use a standalone lexer.

  • Instead of flex + bison, use flex alone (C/C++).
  • Instead of ocamllex + ocamlyacc, use ocamllex alone (OCaml).
  • Ragel (C/C++/Objective C/D/Java/Ruby).

This way you avoid having to define a grammar (which is kind of pointless for log files anyway) and you avoid the dreaded frankenstein-regex-monster sometimes seen in dark places.

like image 104
bltxd Avatar answered Oct 09 '22 06:10

bltxd


I'm not aware of any log parsing libraries. You could always use a general-purpose parser generator, like Boost.Spirit, ANTLR, or lex / yacc; that approach would probably be more work, but it's extremely flexible.

If a parser generator is overkill, then I'd just throw a lot of regexes at the logfiles.

like image 21
Josh Kelley Avatar answered Oct 09 '22 04:10

Josh Kelley