apachelogregex.cr
Version, currently 1.0.01 version
- 1.0.0latestOct 28, 2018
github.com/ab310x/apachelogregex.cr
https://github.com/weppos/apachelogregex ported to crystal lang.
Installation
# Add this to your shard.yml
dependencies:
apachelogregex.cr:
github: ab310x/apachelogregex.cr
version: ~> 1.0.0Then run:
shards installshard.yml
- Crystal
0.26.0- License
- MIT
- Author
- a3104
Dependencies
This version declares no dependencies.
README
apachelogregex.cr
ApacheLogRegex.cr is a crystal lang port of weppos's apachelogregex gem. It provides functionalities to parse a line from an Apache log file into a hash.
Installation
Add this to your application's shard.yml:
dependencies:
apachelogregex.cr:
github: a3104/apachelogregex.cr
Usage
require "apachelogregex"
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.each_line("/var/apache/access.log") do |line|
parser.parse(line)
# {"%r"=>"GET /blog/index.xml HTTP/1.1", "%h"=>"87.18.183.252", ... }
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|
parser.parse(line)
# {"%r"=>"GET /blog/index.xml HTTP/1.1", "%h"=>"87.18.183.252", ... }
end
Contributing
- Fork it (https://github.com/your-github-user/apachelogregex.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- a3104 abe - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.0- Tagged
- Oct 28, 2018
- Commit
4afb35b10938- Crystal
0.26.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/ab310x/apachelogregex.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1