sherlog-holmes 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c34a19741cd97a879215b2062a21a8d930eebf10
4
+ data.tar.gz: 8bcb4667f3a28a6cbd96526897e683a03dd28af7
5
+ SHA512:
6
+ metadata.gz: 35054790cca640f9c83ef34b742e4b2a74fa48439c8e839f89d56900365dc9dae7441e3c2ea233bc68c0066db2e9ba252ac1d6cbfd30c4f7d40b501ee7433a06
7
+ data.tar.gz: a73d9d44a0f4a16e4d2fe397051ab669341626119d010938277dd0efcc8a8418ba0be01b5c4e183e8c73990d430da269daacb970fa4c4b5922a4a460cd16625c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/workspace.xml
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ sherlog-holmes
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <resourceExtensions />
5
+ <wildcardResourcePatterns>
6
+ <entry name="!?*.java" />
7
+ <entry name="!?*.form" />
8
+ <entry name="!?*.class" />
9
+ <entry name="!?*.groovy" />
10
+ <entry name="!?*.scala" />
11
+ <entry name="!?*.flex" />
12
+ <entry name="!?*.kt" />
13
+ <entry name="!?*.clj" />
14
+ <entry name="!?*.aj" />
15
+ </wildcardResourcePatterns>
16
+ <annotationProcessing>
17
+ <profile default="true" name="Default" enabled="false">
18
+ <processorPath useClasspath="true" />
19
+ </profile>
20
+ </annotationProcessing>
21
+ </component>
22
+ </project>
@@ -0,0 +1,3 @@
1
+ <component name="CopyrightManager">
2
+ <settings default="" />
3
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding">
4
+ <file url="PROJECT" charset="UTF-8" />
5
+ </component>
6
+ </project>
data/.idea/misc.xml ADDED
@@ -0,0 +1,176 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="MavenImportPreferences">
4
+ <option name="generalSettings">
5
+ <MavenGeneralSettings>
6
+ <option name="mavenHome" value="Bundled (Maven 3)" />
7
+ </MavenGeneralSettings>
8
+ </option>
9
+ </component>
10
+ <component name="ProjectInspectionProfilesVisibleTreeState">
11
+ <entry key="Project Default">
12
+ <profile-state>
13
+ <expanded-state>
14
+ <State>
15
+ <id />
16
+ </State>
17
+ <State>
18
+ <id>AOP</id>
19
+ </State>
20
+ <State>
21
+ <id>Abstraction issuesJava</id>
22
+ </State>
23
+ <State>
24
+ <id>Android Lint</id>
25
+ </State>
26
+ <State>
27
+ <id>Annotations verifyingGroovy</id>
28
+ </State>
29
+ <State>
30
+ <id>Assignment issuesJava</id>
31
+ </State>
32
+ <State>
33
+ <id>CDI(Contexts and Dependency Injection) issues</id>
34
+ </State>
35
+ <State>
36
+ <id>Class structureJava</id>
37
+ </State>
38
+ <State>
39
+ <id>Cloning issuesJava</id>
40
+ </State>
41
+ <State>
42
+ <id>Code style issuesJava</id>
43
+ </State>
44
+ <State>
45
+ <id>Code style issuesJavaScript</id>
46
+ </State>
47
+ <State>
48
+ <id>Encapsulation issuesJava</id>
49
+ </State>
50
+ <State>
51
+ <id>Error handlingJava</id>
52
+ </State>
53
+ <State>
54
+ <id>Finalization issuesJava</id>
55
+ </State>
56
+ <State>
57
+ <id>General</id>
58
+ </State>
59
+ <State>
60
+ <id>GeneralJavaScript</id>
61
+ </State>
62
+ <State>
63
+ <id>GeneralScala</id>
64
+ </State>
65
+ <State>
66
+ <id>Groovy</id>
67
+ </State>
68
+ <State>
69
+ <id>ImportsJava</id>
70
+ </State>
71
+ <State>
72
+ <id>Inheritance issuesJava</id>
73
+ </State>
74
+ <State>
75
+ <id>Internationalization issues</id>
76
+ </State>
77
+ <State>
78
+ <id>Internationalization issuesJava</id>
79
+ </State>
80
+ <State>
81
+ <id>J2ME issuesJava</id>
82
+ </State>
83
+ <State>
84
+ <id>JPA issues</id>
85
+ </State>
86
+ <State>
87
+ <id>JSON</id>
88
+ </State>
89
+ <State>
90
+ <id>Java</id>
91
+ </State>
92
+ <State>
93
+ <id>Java language level issuesJava</id>
94
+ </State>
95
+ <State>
96
+ <id>Java language level migration aidsJava</id>
97
+ </State>
98
+ <State>
99
+ <id>JavaScript</id>
100
+ </State>
101
+ <State>
102
+ <id>Javadoc issuesJava</id>
103
+ </State>
104
+ <State>
105
+ <id>Language Injection</id>
106
+ </State>
107
+ <State>
108
+ <id>Memory issuesJava</id>
109
+ </State>
110
+ <State>
111
+ <id>Modularization issuesJava</id>
112
+ </State>
113
+ <State>
114
+ <id>Numeric issuesJava</id>
115
+ </State>
116
+ <State>
117
+ <id>Performance issuesJava</id>
118
+ </State>
119
+ <State>
120
+ <id>Portability issuesJava</id>
121
+ </State>
122
+ <State>
123
+ <id>Potentially confusing code constructsGroovy</id>
124
+ </State>
125
+ <State>
126
+ <id>Potentially confusing code constructsJavaScript</id>
127
+ </State>
128
+ <State>
129
+ <id>Probable bugsGroovy</id>
130
+ </State>
131
+ <State>
132
+ <id>Probable bugsJava</id>
133
+ </State>
134
+ <State>
135
+ <id>Properties Files</id>
136
+ </State>
137
+ <State>
138
+ <id>Scala</id>
139
+ </State>
140
+ <State>
141
+ <id>ScaladocScala</id>
142
+ </State>
143
+ <State>
144
+ <id>Security issuesJava</id>
145
+ </State>
146
+ <State>
147
+ <id>Serialization issuesJava</id>
148
+ </State>
149
+ <State>
150
+ <id>Spring</id>
151
+ </State>
152
+ <State>
153
+ <id>Spring CoreSpring</id>
154
+ </State>
155
+ <State>
156
+ <id>Threading issuesGroovy</id>
157
+ </State>
158
+ <State>
159
+ <id>Threading issuesJava</id>
160
+ </State>
161
+ </expanded-state>
162
+ </profile-state>
163
+ </entry>
164
+ </component>
165
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false">
166
+ <OptionsSetting value="true" id="Add" />
167
+ <OptionsSetting value="true" id="Remove" />
168
+ <OptionsSetting value="true" id="Checkout" />
169
+ <OptionsSetting value="true" id="Update" />
170
+ <OptionsSetting value="true" id="Status" />
171
+ <OptionsSetting value="true" id="Edit" />
172
+ <ConfirmationsSetting value="0" id="Add" />
173
+ <ConfirmationsSetting value="0" id="Remove" />
174
+ </component>
175
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="RVM: ruby-2.2-head" project-jdk-type="RUBY_SDK" />
176
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/sherlog-holmes.iml" filepath="$PROJECT_DIR$/.idea/sherlog-holmes.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
7
+ <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
8
+ <sourceFolder url="file://$MODULE_DIR$/bin" isTestSource="false" />
9
+ </content>
10
+ <orderEntry type="inheritedJdk" />
11
+ <orderEntry type="sourceFolder" forTests="false" />
12
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.10.6, RVM: ruby-2.2-head) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="power_assert (v0.2.4, RVM: ruby-2.2-head) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.3.2, RVM: ruby-2.2-head) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="test-unit (v3.1.5, RVM: ruby-2.2-head) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="tins (v1.6.0, RVM: ruby-2.2-head) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="yummi (v0.9.5, RVM: ruby-2.2-head) [gem]" level="application" />
18
+ </component>
19
+ </module>
@@ -0,0 +1,124 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Palette2">
4
+ <group name="Swing">
5
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
+ </item>
8
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
+ </item>
11
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
+ </item>
14
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
+ </item>
17
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
+ <initial-values>
20
+ <property name="text" value="Button" />
21
+ </initial-values>
22
+ </item>
23
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
+ <initial-values>
26
+ <property name="text" value="RadioButton" />
27
+ </initial-values>
28
+ </item>
29
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
+ <initial-values>
32
+ <property name="text" value="CheckBox" />
33
+ </initial-values>
34
+ </item>
35
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
+ <initial-values>
38
+ <property name="text" value="Label" />
39
+ </initial-values>
40
+ </item>
41
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
+ <preferred-size width="150" height="-1" />
44
+ </default-constraints>
45
+ </item>
46
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
+ <preferred-size width="150" height="-1" />
49
+ </default-constraints>
50
+ </item>
51
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
+ <preferred-size width="150" height="-1" />
54
+ </default-constraints>
55
+ </item>
56
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
+ <preferred-size width="150" height="50" />
59
+ </default-constraints>
60
+ </item>
61
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
+ <preferred-size width="150" height="50" />
64
+ </default-constraints>
65
+ </item>
66
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
+ <preferred-size width="150" height="50" />
69
+ </default-constraints>
70
+ </item>
71
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
+ </item>
74
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
+ <preferred-size width="150" height="50" />
77
+ </default-constraints>
78
+ </item>
79
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
+ <preferred-size width="150" height="50" />
82
+ </default-constraints>
83
+ </item>
84
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
+ <preferred-size width="150" height="50" />
87
+ </default-constraints>
88
+ </item>
89
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
+ <preferred-size width="200" height="200" />
92
+ </default-constraints>
93
+ </item>
94
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
+ <preferred-size width="200" height="200" />
97
+ </default-constraints>
98
+ </item>
99
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
+ </item>
102
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
+ </item>
105
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
+ </item>
108
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
+ </item>
111
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
+ <preferred-size width="-1" height="20" />
114
+ </default-constraints>
115
+ </item>
116
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
+ </item>
119
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
+ </item>
122
+ </group>
123
+ </component>
124
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sherlog-holmes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ataxexe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Sherlog Holmes
2
+
3
+ This is a gem to help the analysis of logs
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sherlog_holmes'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sherlog-holmes
20
+
21
+ ## Usage
22
+
23
+ Shelog Holmes provides a command line tool `sherlog`. Execute `sherlog -h` to see the options and command usage.
24
+
25
+ ## License
26
+
27
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
28
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/sherlog ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yummi'
4
+ require 'optionparser'
5
+
6
+ require_relative '../lib/sherlog_holmes'
7
+
8
+ include Sherlog
9
+
10
+ @opts = OptionParser::new
11
+ @filter_params = {}
12
+ @params = {}
13
+
14
+ @opts.banner = 'Usage: sherlog [options] <logfile>'
15
+
16
+ @opts.on '-c EXPRESSION', '--category EXPRESSION', 'Set the category filter regexp' do |expression|
17
+ @filter_params[:category] = expression
18
+ end
19
+
20
+ @opts.on '-l EXPRESSION', '--level EXPRESSION', 'Set the level filter regexp' do |expression|
21
+ @filter_params[:level] = expression
22
+ end
23
+
24
+ [:error, :info, :warn, :debug, :fatal].each do |level|
25
+ @opts.on "--#{level}", "Filter #{level.upcase} logs" do
26
+ if @filter_params[:level]
27
+ @filter_params[:level] += "|#{level}"
28
+ else
29
+ @filter_params[:level] = level.to_s
30
+ end
31
+ end
32
+ end
33
+
34
+ @opts.on '-m EXPRESSION', '--message EXPRESSION', 'Set the message filter regexp' do |expression|
35
+ @filter_params[:message] = expression
36
+ end
37
+
38
+ @opts.on '-e EXPRESSION', '--exception EXPRESSION', 'Sets the exception filter regexp' do |expression|
39
+ @filter_params[:exception] = expression
40
+ end
41
+
42
+ @opts.on '--no-stacktrace', 'Omits the stacktrace when showing log entries' do
43
+ @params[:stacktrace] = false
44
+ end
45
+
46
+ @opts.on '--only-exceptions', 'Filter only exception entries' do
47
+ @only_exceptions = true
48
+ end
49
+
50
+ @opts.on '--show-log', 'Shows the filtered entries' do
51
+ @print_log = true
52
+ end
53
+
54
+ @opts.on '--show-info', 'Shows information about the filtered entries' do
55
+ @print_info = true
56
+ end
57
+
58
+ @opts.on '--show-exception', 'Shows filtered entries that contains an exception' do
59
+ @print_exception_entries = true
60
+ end
61
+
62
+ @opts.on '--show-exception-info', 'Shows filtered entries that contains an exception' do
63
+ @print_exception_info = true
64
+ end
65
+
66
+ @opts.on '-h', '--help', 'Shows the usage help' do
67
+ puts @opts
68
+ exit
69
+ end
70
+
71
+ @opts.parse! ARGV
72
+
73
+ file = ARGV.first
74
+ filter = LogFilter::new
75
+ filter.exceptions if @only_exceptions
76
+ @filter_params.each do |param, expression|
77
+ filter.send param, expression
78
+ end
79
+ log = LogFile::new file, filter, @params
80
+ log.read
81
+ log.print_info if @print_info
82
+ log.print_exception_info if @print_exception_info
83
+ log.print_exception_entries if @print_exception_entries
84
+ log.print_entries if @print_log
@@ -0,0 +1,37 @@
1
+ module Sherlog
2
+ class LogEntry
3
+
4
+ attr_accessor :time, :level, :category, :origin, :message, :exception_class
5
+
6
+ def initialize(params = {})
7
+ @time = params[:time]
8
+ @level = params[:level]
9
+ @category = params[:category]
10
+ @origin = params[:origin]
11
+ @message = params[:message]
12
+ @stacktrace = []
13
+ data = /(\w+(\.\w+)+(Exception|Error))/.match @message
14
+ if data
15
+ @exception_class = data[1]
16
+ end
17
+ end
18
+
19
+ def exception?
20
+ !@exception_class.nil?
21
+ end
22
+
23
+ def <<(line)
24
+ @stacktrace << line
25
+ end
26
+
27
+ def to_s
28
+ string = if origin
29
+ '%s %s [%s] (%s) %s' % [time, level.ljust(7), category, origin, message]
30
+ else
31
+ '%s %s [%s] %s' % [time, level.ljust(7), category, message]
32
+ end
33
+ ([string] + @stacktrace).join($/)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,88 @@
1
+ module Sherlog
2
+ class LogFile
3
+
4
+ attr_reader :entries, :file
5
+
6
+ def initialize(logfile, filter, params = {})
7
+ @file = logfile
8
+ @params = {
9
+ stacktrace: true
10
+ }.merge params
11
+ @filter = filter
12
+ @entries = []
13
+ @exceptions = {}
14
+ @map = {}
15
+ end
16
+
17
+ def read
18
+ # time level category origin message
19
+ regexp = /([0-9,.:]+)\s+(\w+)\s+\[(\S+)\]\s(\(\S+\))?\s?(.+)/
20
+ entry = nil
21
+ IO.foreach(file) do |line|
22
+ data = regexp.match line.chomp
23
+ if data
24
+ entry = LogEntry::new time: data[1],
25
+ level: data[2],
26
+ category: data[3],
27
+ origin: data[4].to_s[1..-1],
28
+ message: data[5]
29
+ if @filter.accept? entry
30
+ @entries << entry
31
+ if entry.exception?
32
+ @exceptions[entry.exception_class] ||= []
33
+ @exceptions[entry.exception_class] << entry
34
+ end
35
+ @map[entry.level] ||= {}
36
+ @map[entry.level][entry.category] ||= []
37
+
38
+ @map[entry.level][entry.category] << entry
39
+ end
40
+ else
41
+ entry << line.chomp if entry and @params[:stacktrace]
42
+ end
43
+ end
44
+ end
45
+
46
+ def print_info(target = $stdout)
47
+ @map.each do |level, categories|
48
+ table = Yummi::Table::new
49
+ table.title = 'Entries for %s level by category' % level
50
+ table.header = %w(Category Count)
51
+ table.colorize :category, with: 'bold.white'
52
+ table.colorize :count, with: 'magenta'
53
+ categories.sort_by { |k, v| v.size }.each do |category, entries|
54
+ table << [category, entries.size]
55
+ end
56
+ table.print target
57
+ target.print $/
58
+ end
59
+ end
60
+
61
+ def print_entries(target = $stdout)
62
+ @entries.each do |entry|
63
+ target.print entry.to_s + $/
64
+ end
65
+ end
66
+
67
+ def print_exception_entries(target = $stdout)
68
+ @entries.each do |entry|
69
+ target.print entry.to_s + $/ if entry.exception?
70
+ end
71
+ end
72
+
73
+ def print_exception_info(target = $stdout)
74
+ unless @exceptions.empty?
75
+ table = Yummi::Table::new
76
+ table.title = 'Exceptions by class'
77
+ table.header = %w(Class Count)
78
+ table.colorize :class, with: 'bold.white'
79
+ table.colorize :count, with: 'magenta'
80
+ @exceptions.sort_by { |k, v| v.size }.each do |exception_class, entries|
81
+ table << [exception_class, entries.size]
82
+ end
83
+ table.print target
84
+ end
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,48 @@
1
+ module Sherlog
2
+ class LogFilter
3
+
4
+ def initialize
5
+ @filters = []
6
+ end
7
+
8
+ def filter(filter = nil, &block)
9
+ @filters << filter if filter
10
+ @filters << block if block
11
+ end
12
+
13
+ def level(expression)
14
+ filter do |entry|
15
+ /#{expression}/i.match entry.level
16
+ end
17
+ end
18
+
19
+ def category(expression)
20
+ filter do |entry|
21
+ /#{expression}/.match entry.category
22
+ end
23
+ end
24
+
25
+ def message(expression)
26
+ filter do |entry|
27
+ /#{expression}/i.match entry.category
28
+ end
29
+ end
30
+
31
+ def exception(expression)
32
+ filter do |entry|
33
+ /#{expression}/.match entry.category
34
+ end
35
+ end
36
+
37
+ def exceptions
38
+ self << lambda do |entry|
39
+ entry.exception?
40
+ end
41
+ end
42
+
43
+ def accept?(entry)
44
+ @filters.all? { |filter| filter.call entry }
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Sherlog
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ require_relative 'sherlog_holmes/version'
2
+ require_relative 'sherlog_holmes/log_entry'
3
+ require_relative 'sherlog_holmes/log_filter'
4
+ require_relative 'sherlog_holmes/log_file'
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sherlog_holmes/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'sherlog-holmes'
8
+ spec.version = Sherlog::VERSION
9
+ spec.authors = ['Ataxexe']
10
+ spec.email = ['ataxexe@devnull.tools']
11
+
12
+ spec.summary = %q{A gem to analyse log files}
13
+ spec.homepage = 'https://github.com/devnull-tools/sherlog-holmes'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'bin'
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'yummi', '~> 0.9.5'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'test-unit'
26
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sherlog-holmes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ataxexe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yummi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - ataxexe@devnull.tools
72
+ executables:
73
+ - sherlog
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".idea/.name"
79
+ - ".idea/compiler.xml"
80
+ - ".idea/copyright/profiles_settings.xml"
81
+ - ".idea/encodings.xml"
82
+ - ".idea/misc.xml"
83
+ - ".idea/modules.xml"
84
+ - ".idea/sherlog-holmes.iml"
85
+ - ".idea/uiDesigner.xml"
86
+ - ".idea/vcs.xml"
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/sherlog
92
+ - lib/sherlog_holmes.rb
93
+ - lib/sherlog_holmes/log_entry.rb
94
+ - lib/sherlog_holmes/log_file.rb
95
+ - lib/sherlog_holmes/log_filter.rb
96
+ - lib/sherlog_holmes/version.rb
97
+ - sherlog-holmes.gemspec
98
+ homepage: https://github.com/devnull-tools/sherlog-holmes
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.4.6
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: A gem to analyse log files
122
+ test_files: []