sawmill 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/README.rdoc +11 -5
- data/Version +1 -1
- data/lib/sawmill.rb +1 -0
- data/lib/sawmill/entry_processor/filter_by_message.rb +96 -0
- data/lib/sawmill/railtie.rb +11 -1
- data/test/tc_entry_processors.rb +15 -0
- metadata +6 -5
data/History.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.1.17 / 2012-12-14
|
2
|
+
|
3
|
+
* The Rails config now supports an entry_filter setting, which lets you pre-filter log entries before they get handed over to the formatter.
|
4
|
+
* Implemented Sawmill::EntryProcessor::FilterByMessage.
|
5
|
+
* The gemspec no longer includes the timestamp in the version, so that bundler can pull from github. (Reported by corneverbruggen)
|
6
|
+
|
1
7
|
=== 0.1.16 / 2012-06-04
|
2
8
|
|
3
9
|
* The :local_time and :iso_8601_time arguments to Sawmill::EntryProcessor::Format didn't have their advertised effect. Fixed.
|
data/README.rdoc
CHANGED
@@ -27,7 +27,7 @@ Sawmill is an extension to the standard ruby Logger mechanism that enables autom
|
|
27
27
|
=== Requirements
|
28
28
|
|
29
29
|
* Ruby 1.8.7 or later (Ruby 1.9.2 or later recommended), or JRuby 1.4 or later.
|
30
|
-
* Blockenspiel 0.4.
|
30
|
+
* Blockenspiel 0.4.5 or later.
|
31
31
|
|
32
32
|
=== Installation
|
33
33
|
|
@@ -39,23 +39,29 @@ Sawmill is currently under development, and some features are not yet complete o
|
|
39
39
|
|
40
40
|
=== Development and support
|
41
41
|
|
42
|
-
Documentation is available at http://
|
42
|
+
Documentation is available at http://dazuma.github.com/sawmill/rdoc
|
43
43
|
|
44
44
|
Source code is hosted on Github at http://github.com/dazuma/sawmill
|
45
45
|
|
46
|
+
Contributions are welcome. Fork the project on Github.
|
47
|
+
|
48
|
+
Build status: {<img src="https://secure.travis-ci.org/dazuma/sawmill.png" />}[http://travis-ci.org/dazuma/sawmill]
|
49
|
+
|
46
50
|
Report bugs on Github issues at http://github.org/dazuma/sawmill/issues
|
47
51
|
|
48
52
|
Contact the author at dazuma at gmail dot com.
|
49
53
|
|
50
54
|
=== Author / Credits
|
51
55
|
|
52
|
-
Sawmill is written by Daniel Azuma (http://www.daniel-azuma.com
|
56
|
+
Sawmill is written by Daniel Azuma (http://www.daniel-azuma.com).
|
57
|
+
|
58
|
+
Development is supported by Pirq (http://www.pirq.com).
|
53
59
|
|
54
|
-
|
60
|
+
Continuous integration service provided by Travis-CI (http://travis-ci.org).
|
55
61
|
|
56
62
|
=== License
|
57
63
|
|
58
|
-
Copyright 2009-
|
64
|
+
Copyright 2009-2012 Daniel Azuma.
|
59
65
|
|
60
66
|
All rights reserved.
|
61
67
|
|
data/Version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.17
|
data/lib/sawmill.rb
CHANGED
@@ -53,6 +53,7 @@ require 'sawmill/entry_processor'
|
|
53
53
|
require 'sawmill/entry_processor/conditionals'
|
54
54
|
require 'sawmill/entry_processor/simple_queue'
|
55
55
|
require 'sawmill/entry_processor/filter_by_basic_fields'
|
56
|
+
require 'sawmill/entry_processor/filter_by_message'
|
56
57
|
require 'sawmill/entry_processor/filter_by_block'
|
57
58
|
require 'sawmill/entry_processor/build_records'
|
58
59
|
require 'sawmill/entry_processor/format'
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Sawmill entry processor that checks message content.
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2012 Daniel Azuma
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
11
|
+
# modification, are permitted provided that the following conditions are met:
|
12
|
+
#
|
13
|
+
# * Redistributions of source code must retain the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer.
|
15
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer in the documentation
|
17
|
+
# and/or other materials provided with the distribution.
|
18
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
+
# contributors to this software, may be used to endorse or promote products
|
20
|
+
# derived from this software without specific prior written permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
# -----------------------------------------------------------------------------
|
34
|
+
;
|
35
|
+
|
36
|
+
|
37
|
+
module Sawmill
|
38
|
+
|
39
|
+
module EntryProcessor
|
40
|
+
|
41
|
+
|
42
|
+
# A basic filter that knows how to check message content.
|
43
|
+
#
|
44
|
+
# This is a boolean processor, so it merely returns true or false based
|
45
|
+
# on the filter result. Use this in conjunction with an If processor to
|
46
|
+
# actually perform other actions based on the result.
|
47
|
+
|
48
|
+
class FilterByMessage < Base
|
49
|
+
|
50
|
+
|
51
|
+
# Create a new filter. you must provide content, which can be a
|
52
|
+
# string or a regex.
|
53
|
+
#
|
54
|
+
# Recognized options include:
|
55
|
+
#
|
56
|
+
# [<tt>:accept_non_messages</tt>]
|
57
|
+
# If set to true, accepts entries that are not messages. Otherwise,
|
58
|
+
# if set to false or not specified, rejects such entries.
|
59
|
+
|
60
|
+
def initialize(content_, opts_={})
|
61
|
+
@content = content_
|
62
|
+
@accept_non_messages = opts_[:accept_non_messages] ? true : false
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def begin_record(entry_)
|
67
|
+
@accept_non_messages
|
68
|
+
end
|
69
|
+
|
70
|
+
def end_record(entry_)
|
71
|
+
@accept_non_messages
|
72
|
+
end
|
73
|
+
|
74
|
+
def message(entry_)
|
75
|
+
@content === entry_.message
|
76
|
+
end
|
77
|
+
|
78
|
+
def attribute(entry_)
|
79
|
+
@accept_non_messages
|
80
|
+
end
|
81
|
+
|
82
|
+
def unknown_data(entry_)
|
83
|
+
@accept_non_messages
|
84
|
+
end
|
85
|
+
|
86
|
+
def finish
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
data/lib/sawmill/railtie.rb
CHANGED
@@ -81,12 +81,17 @@ module Sawmill
|
|
81
81
|
@elapsed_time_attribute = nil
|
82
82
|
@pre_logger = nil
|
83
83
|
@post_logger = nil
|
84
|
+
@entry_filter = nil
|
84
85
|
end
|
85
86
|
|
86
87
|
# The log file to write to. This should be either an IO object, or
|
87
88
|
# a Sawmill::Rotater. Default is STDERR.
|
88
89
|
attr_accessor :logfile
|
89
90
|
|
91
|
+
# An optional filter to run on log entries before they get passed
|
92
|
+
# to the formatter.
|
93
|
+
attr_accessor :entry_filter
|
94
|
+
|
90
95
|
# This option is passed to Sawmill::EntryProcessor::Format::new
|
91
96
|
attr_accessor :include_id
|
92
97
|
# This option is passed to Sawmill::EntryProcessor::Format::new
|
@@ -156,8 +161,13 @@ module Sawmill
|
|
156
161
|
:local_time => myconfig_.local_time,
|
157
162
|
:iso_8601_time => myconfig_.iso_8601_time,
|
158
163
|
:length_limit => myconfig_.length_limit)
|
164
|
+
if (filter_ = myconfig_.entry_filter)
|
165
|
+
processor_ = EntryProcessor::If.new(filter_, formatter_)
|
166
|
+
else
|
167
|
+
processor_ = formatter_
|
168
|
+
end
|
159
169
|
logger_ = Logger.new(
|
160
|
-
:processor =>
|
170
|
+
:processor => processor_,
|
161
171
|
:level => myconfig_.level,
|
162
172
|
:attribute_level => myconfig_.attribute_level,
|
163
173
|
:progname => myconfig_.progname,
|
data/test/tc_entry_processors.rb
CHANGED
@@ -81,6 +81,21 @@ module Sawmill
|
|
81
81
|
end
|
82
82
|
|
83
83
|
|
84
|
+
# Test a message filter
|
85
|
+
|
86
|
+
def test_basic_message_filter
|
87
|
+
processor_ = ::Sawmill::EntryProcessor::build do
|
88
|
+
If(FilterByMessage(/hello/), @entries)
|
89
|
+
end
|
90
|
+
@logger = ::Sawmill::Logger.new(:processor => processor_)
|
91
|
+
@logger.info('hi Hello')
|
92
|
+
@logger.info('ho hello')
|
93
|
+
@logger.info('he Hello')
|
94
|
+
assert_equal('ho hello', @entries.dequeue.message)
|
95
|
+
assert_equal(0, @entries.size)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
84
99
|
# Test an "AND" filter
|
85
100
|
|
86
101
|
def test_conjunction_and
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sawmill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blockenspiel
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.4.
|
21
|
+
version: 0.4.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.4.
|
29
|
+
version: 0.4.5
|
30
30
|
description: Sawmill is a logging and log analysis system for Ruby. It extends the
|
31
31
|
basic Ruby logging facility with log records and parsing abilities.
|
32
32
|
email: dazuma@gmail.com
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/sawmill/entry_processor/count_entries.rb
|
45
45
|
- lib/sawmill/entry_processor/filter_by_basic_fields.rb
|
46
46
|
- lib/sawmill/entry_processor/filter_by_block.rb
|
47
|
+
- lib/sawmill/entry_processor/filter_by_message.rb
|
47
48
|
- lib/sawmill/entry_processor/format.rb
|
48
49
|
- lib/sawmill/entry_processor/interpret_stats.rb
|
49
50
|
- lib/sawmill/entry_processor/simple_queue.rb
|
@@ -89,7 +90,7 @@ files:
|
|
89
90
|
- History.rdoc
|
90
91
|
- README.rdoc
|
91
92
|
- Version
|
92
|
-
homepage: http://
|
93
|
+
homepage: http://dazuma.github.com/sawmill
|
93
94
|
licenses: []
|
94
95
|
post_install_message:
|
95
96
|
rdoc_options: []
|