
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
= Apache Log Regex
Apache Log Regex is a Ruby port of Peter Hickman's Apache::LogRegex 1.4 Perl module, available at http://cpan.uwinnipeg.ca/~peterhi/Apache-LogRegex. It provides functionalities to parse a line from an Apache log file into a hash.
== Dependencies
ApacheLogRegex is compatible with Ruby 1.9.1.
== Overview
Apache Log Regex is designed to be a simple class to parse Apache log files.
It takes an Apache logging format and generates a regular expression which is used to parse a line from a log file and returns a Hash with keys corresponding to the fields defined in the log format. The log format should match the one defined in your Apache configuration file with the LogFormat directive.
== Example Usage
The following one is the most simple example usage.
It tries to parse the access.log
file and echoes each parsed line.
format = '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"' parser = ApacheLogRegex.new(format)
File.foreach('/var/apache/access.log') do |line| begin parser.parse(line) # {"%r"=>"GET /blog/index.xml HTTP/1.1", "%h"=>"87.18.183.252", ... } rescue ApacheLogRegex::ParseError => e puts "Error parsing log file: " + e.message end end
More often, you might want to collect parsed lines and use them later in your program. The following example iterates all log lines, parses them and returns an array of Hash with the results.
format = '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"' parser = ApacheLogRegex.new(format)
File.readlines('/var/apache/access.log').collect do |line| begin parser.parse(line) # {"%r"=>"GET /blog/index.xml HTTP/1.1", "%h"=>"87.18.183.252", ... } rescue ApacheLogRegex::ParseError => e nil end end
== Acknowledgments
This library is essentially a Ruby port of Apache::LogRegex Perl library. A big thanks goes to Peter Hickman, the author of the original package. This Ruby GEM would probably not exists without your contribution!
I also want to thank you Harry Fuecks and Hamish Morgan, the authors of the Python[http://code.google.com/p/apachelog/] and PHP[http://kitty0.org/] ports. First of all they gave me the inspiration to translate the original Perl code to Ruby, as soon as I discovered nobody did it before me. Last but not least, their library have been extremely useful to help me understand some obscure Perl statements from the original package.
== Author
{Simone Carletti}[http://www.simonecarletti.com/] weppos@weppos.net
== Resources
== FeedBack and Bug reports
Feel free to email {Simone Carletti}[mailto:weppos@weppos.net] with any questions or feedback.
Please use the {Ticket System}[http://code.simonecarletti.com/projects/show/apachelogregex] to submit bug reports or feature request.
== Changelog
See the CHANGELOG.rdoc file for details.
== License
Copyright (c) 2008-2009 Simone Carletti, ApacheLogRegex is released under the MIT license.
FAQs
Unknown package
We found that apachelogregex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.