batlog 0.9 → 0.9.1
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.
- data/.gitignore +2 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -3
- data/lib/log/log.rb +1 -0
- data/lib/log/version.rb +1 -1
- data/spec/lib/log_spec.rb +26 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helpers/test_logger.rb +20 -0
- metadata +5 -2
data/.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
.idea
|
|
1
|
+
.idea
|
|
2
|
+
*.gem
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
### 0.9.1 - bug fixes
|
|
3
|
+
* BUGFIX - post a message without context
|
|
4
|
+
### 0.9 - Initial Release
|
|
5
|
+
* Basic Functionality
|
|
6
|
+
* Log.info,warn,debug,error,fatal
|
|
7
|
+
* Log.assert
|
|
8
|
+
* Log.context
|
|
9
|
+
* Log.events
|
|
10
|
+
* 3 Loggers
|
|
11
|
+
* Database logger
|
|
12
|
+
* Rails logger
|
|
13
|
+
* Exceptional logger
|
|
14
|
+
* Log::ControllerSupport
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
# BatLog v0.9
|
|
1
|
+
# BatLog v0.9.1 [](http://travis-ci.org/TheGiftsProject/batlog)
|
|
2
2
|

|
|
3
3
|
|
|
4
4
|
## Setup
|
|
5
|
-
To install BatLog into your Rails app just
|
|
5
|
+
To install BatLog into your Rails app just the gem to your Gemfile
|
|
6
|
+
```ruby
|
|
7
|
+
gem 'batlog'
|
|
8
|
+
```
|
|
9
|
+
After that run `rails generate db_log` to create the db_log's table migration.
|
|
6
10
|
By default BatLog writes to three places - the database, the rails logger and exceptions to exceptional
|
|
7
11
|
You can overide this behaivour by providing your own loggers or changing the default logger in the configuration.
|
|
8
12
|
|
|
@@ -102,7 +106,7 @@ all subsequent loggers.
|
|
|
102
106
|
|
|
103
107
|
|
|
104
108
|
### Controller Support
|
|
105
|
-
Also included with BatLog is the log controller support
|
|
109
|
+
Also included with BatLog is the log controller support. To use it we recommend you add it to your ApplicationController
|
|
106
110
|
by adding these lines to it.
|
|
107
111
|
```ruby
|
|
108
112
|
require 'log/controller_support'
|
data/lib/log/log.rb
CHANGED
data/lib/log/version.rb
CHANGED
data/spec/lib/log_spec.rb
CHANGED
|
@@ -17,7 +17,33 @@ describe Log do
|
|
|
17
17
|
subject.clear_events
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
describe "basics" do
|
|
21
|
+
|
|
22
|
+
before do
|
|
23
|
+
Log.config.loggers = [ Log::TestLogger ]
|
|
24
|
+
Log::TestLogger.reset
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should be able to write a message without a context" do
|
|
28
|
+
Log.info("test")
|
|
29
|
+
Log::TestLogger.logs.count.should == 1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should be able to write a message with a context" do
|
|
33
|
+
Log.info("test", :a => 1)
|
|
34
|
+
Log::TestLogger.logs.count.should == 1
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should be able to write a message with a context and an event" do
|
|
38
|
+
Log.info("test", {:a => 1}, [{:name => 1, :data => 2}])
|
|
39
|
+
Log::TestLogger.logs.count.should == 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
20
44
|
describe "log.writes" do
|
|
45
|
+
|
|
46
|
+
|
|
21
47
|
shared_examples_for "log severity" do |severity|
|
|
22
48
|
context "when message is a LoggableError" do
|
|
23
49
|
it "adds the log data to the context" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Log
|
|
2
|
+
class TestLogger
|
|
3
|
+
|
|
4
|
+
LogMessage = Struct.new(:severity, :message, :context, :events, :metadata)
|
|
5
|
+
|
|
6
|
+
def self.log(severity, message, context, events, metadata)
|
|
7
|
+
logs << LogMessage.new(severity, message, context, events, metadata)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.logs
|
|
11
|
+
@logs ||= reset
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.reset
|
|
15
|
+
@logs = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: batlog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 57
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.9.1
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Asaf Gartner
|
|
@@ -73,6 +74,7 @@ files:
|
|
|
73
74
|
- .rspec
|
|
74
75
|
- .rvmrc
|
|
75
76
|
- .travis.yml
|
|
77
|
+
- CHANGELOG.md
|
|
76
78
|
- Gemfile
|
|
77
79
|
- Gemfile.lock
|
|
78
80
|
- README.md
|
|
@@ -96,6 +98,7 @@ files:
|
|
|
96
98
|
- spec/lib/log_spec.rb
|
|
97
99
|
- spec/lib/loggable_error_spec.rb
|
|
98
100
|
- spec/spec_helper.rb
|
|
101
|
+
- spec/spec_helpers/test_logger.rb
|
|
99
102
|
homepage: https://github.com/TheGiftsProject/batlog
|
|
100
103
|
licenses: []
|
|
101
104
|
|