bunyan 0.2.2 → 0.3.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.
- data/CHANGELOG.md +4 -0
- data/README.md +4 -1
- data/VERSION +1 -1
- data/bunyan.gemspec +2 -2
- data/lib/bunyan.rb +1 -1
- data/lib/bunyan/config.rb +10 -0
- data/spec/config_spec.rb +42 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,8 @@ For rails apps, put the following config block in an initializer.
|
|
22
22
|
config.collection 'development_log'
|
23
23
|
|
24
24
|
# optional
|
25
|
+
config.host 'some.remote.host' # defaults to localhost
|
26
|
+
config.port '12345' # defaults to 27017
|
25
27
|
config.disabled true
|
26
28
|
end
|
27
29
|
|
@@ -56,8 +58,9 @@ More
|
|
56
58
|
|
57
59
|
TODO
|
58
60
|
====
|
61
|
+
* Ability to specify auth creds for making mongo connection
|
59
62
|
* <del>Fail silently if no mongo server running</del>
|
60
63
|
* Ability to limit bunyan to only run in certain environments
|
61
64
|
* Add middleware client for easy drop-in to rails/rack apps
|
62
|
-
|
65
|
+
<del>* Add ability to connect to a remote mongo server</del>
|
63
66
|
* <del>Ability to configure size of capped collection</del>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bunyan.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bunyan}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex Sharp"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-12}
|
13
13
|
s.description = %q{Bunyan is a thin ruby wrapper around a MongoDB capped collection, created with high-performance, flexible logging in mind.}
|
14
14
|
s.email = %q{ajsharp@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/bunyan.rb
CHANGED
@@ -58,7 +58,7 @@ module Bunyan
|
|
58
58
|
private
|
59
59
|
def initialize_connection
|
60
60
|
begin
|
61
|
-
@db = Mongo::Connection.new.db(config.database)
|
61
|
+
@db = Mongo::Connection.new(config.host, config.port).db(config.database)
|
62
62
|
@connection = @db.connection
|
63
63
|
@collection = retrieve_or_initialize_collection(config.collection)
|
64
64
|
rescue Mongo::ConnectionFailure => ex
|
data/lib/bunyan/config.rb
CHANGED
@@ -15,6 +15,16 @@ module Bunyan
|
|
15
15
|
send(meth)
|
16
16
|
end
|
17
17
|
|
18
|
+
def port(port_num = nil)
|
19
|
+
@port ||= port_num
|
20
|
+
end
|
21
|
+
alias_method :port=, :port
|
22
|
+
|
23
|
+
def host(host_address = nil)
|
24
|
+
@host ||= host_address
|
25
|
+
end
|
26
|
+
alias_method :host=, :host
|
27
|
+
|
18
28
|
# First time called sets the database name.
|
19
29
|
# Otherwise, returns the database name.
|
20
30
|
def database(db_name = nil)
|
data/spec/config_spec.rb
CHANGED
@@ -116,3 +116,45 @@ describe Bunyan::Logger::Config, "#disabled?" do
|
|
116
116
|
@config.should_not be_disabled
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
describe 'when we configure a remote host' do
|
121
|
+
def configure_with_remote_host
|
122
|
+
Bunyan::Logger.configure do |c|
|
123
|
+
c.host 'some.remote.host'
|
124
|
+
c.database 'test_db'
|
125
|
+
c.collection 'test_collection'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should attempt to connect to the remote host' do
|
130
|
+
Mongo::Connection.should_receive(:new).with('some.remote.host', nil)
|
131
|
+
configure_with_remote_host
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should set the host config option' do
|
135
|
+
configure_with_remote_host
|
136
|
+
Bunyan::Logger.config.host.should == 'some.remote.host'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe 'when we configure a port' do
|
141
|
+
def configure_with_remote_port
|
142
|
+
Bunyan::Logger.configure do |c|
|
143
|
+
c.host 'some.remote.host'
|
144
|
+
c.port '20910'
|
145
|
+
c.database 'test_db'
|
146
|
+
c.collection 'test_collection'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should attempt to connect to a remote port' do
|
151
|
+
Mongo::Connection.should_receive(:new).with('some.remote.host', '20910')
|
152
|
+
configure_with_remote_port
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should set the port config option' do
|
156
|
+
configure_with_remote_port
|
157
|
+
Bunyan::Logger.config.port.should == '20910'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alex Sharp
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-12 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|