Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add desc for parsers

  • Loading branch information...
commit ee28e7db186554985603a6411d5d1fdc47a24428 1 parent 604c39e
John Tajima authored tobi committed
View
10 lib/parsers/hostname_parser.rb
@@ -1,12 +1,16 @@
class HostnameParser
- # sample log output
+ # given a string in format:
+ #
# app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
- # or
# 129.123.2.1 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
+ #
+ # strips out the hostname/IP and appname
+ #
+ # result => [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
+
- # parse out ip/hostapp : line
LineRegexp = /^([\w-]+|\d+\.\d+\.\d+\.\d+)\s([^:]*):\s*(.*)/
attr_accessor :elements, :next_parser
View
11 lib/parsers/shop_parser.rb
@@ -1,8 +1,15 @@
class ShopParser
+ # given a string in format:
+ #
# [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
-
- # parse out the shop name
+ #
+ # strips out the shop name
+ #
+ # result => :shop => wadedemt.myshopify.com
+ # :line => Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
+
+
LineRegexp = /^\s*\[([a-zA-Z0-9\-.]+)\]\s*(.*)/
attr_accessor :elements
View
30 lib/parsers/time_parser.rb
@@ -1,18 +1,26 @@
class TimeParser
-
- # sample log output
- # Jul 24 14:58:21 app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
- # 1 date
- # 2 app
- # 3 shop
- # 4 line
- # parse out :timestamp, :line
+ # strips out timestamp and if start/end times are defined, will reject lines that don't fall within proper time periods
+ #
+ # entry format:
+ # Jul 24 14:58:21 app3 rails.shopify[9855]: [wadedemt.myshopify.com] Processing ShopController#products (for 192.168.1.230 at 2009-07-24 14:58:21) [GET]
+ #
+ # params = {
+ # 'sh' => start hour
+ # 'sm' => start minute
+ # 'ss' => start second
+ # 'eh' => end hour
+ # 'em' => end minute
+ # 'es' => end second
+ # }
+ #
+ # if 'sh' is defined, reject any lines where timestamp is earlier than start time
+ # if 'eh' is defined, reject any lines where timestamp is later than end time
+ # if 'sh' && 'eh' is defined, reject any lines where timestamp is not between start time and end time
+
LineRegexp = /^(\w+\s+\d+\s\d\d:\d\d:\d\d)\s(.*)/
-
- OFFSET = 4 * 60 * 60 # est offset
-
+
attr_accessor :elements, :params
def initialize(next_renderer = nil, params = {})
Please sign in to comment.
Something went wrong with that request. Please try again.