logtrend 0.7.20101205083841 → 0.8.20101205091549

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/logtrend.rb +23 -0
  2. data/samples/test.log +2 -0
  3. metadata +18 -4
@@ -3,6 +3,7 @@ require 'eventmachine'
3
3
  require 'eventmachine-tail'
4
4
  require 'rrd'
5
5
  require 'logger'
6
+ require 'erb'
6
7
 
7
8
  module LogTrend
8
9
  class Base
@@ -15,6 +16,19 @@ module LogTrend
15
16
  @graphs = []
16
17
  @logger = Logger.new(STDERR)
17
18
  @logger.level = ($DEBUG and Logger::DEBUG or Logger::WARN)
19
+
20
+ @template = ERB.new <<-EOF
21
+ <html>
22
+ <head>
23
+ <title>logtrend</title>
24
+ </head>
25
+ <body>
26
+ <% @graphs.each do |graph| %>
27
+ <img src='<%=graph.name%>.png' />
28
+ <% end %>
29
+ </body>
30
+ </html>
31
+ EOF
18
32
  end
19
33
 
20
34
  def add_trend(name, &block)
@@ -44,6 +58,7 @@ module LogTrend
44
58
  @logger.debug "#{Time.now} #{counters.inspect}"
45
59
  counters.each {|name, value| update_rrd(name, value)}
46
60
  @graphs.each {|graph| build_graph(graph)}
61
+ build_page
47
62
  counters = reset_counters
48
63
  end
49
64
 
@@ -90,6 +105,14 @@ module LogTrend
90
105
  end
91
106
  end
92
107
  end
108
+
109
+ def build_page
110
+ file_name = File.join(@graphs_dir,'index.html')
111
+ File.open(file_name, "w") do |f|
112
+ f << @template.result(binding)
113
+ end
114
+ end
115
+
93
116
  end
94
117
 
95
118
  class Graph
@@ -38,3 +38,5 @@ test
38
38
  test
39
39
  test
40
40
  test
41
+ 10
42
+ 100
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtrend
3
3
  version: !ruby/object:Gem::Version
4
- hash: 40202410167681
4
+ hash: 40202410183045
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 20101205083841
10
- version: 0.7.20101205083841
8
+ - 8
9
+ - 20101205091549
10
+ version: 0.8.20101205091549
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Gorsuch
@@ -60,6 +60,20 @@ dependencies:
60
60
  version: "0"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: erb
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
63
77
  description: logtrend is an HTTP log parser built on top of event machine, generating rrd graphs of usage matching patterns you define.
64
78
  email: michael.gorsuch@gmail.com
65
79
  executables: []