winston_mongodb_rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Winston Mongodb Rails
|
2
2
|
|
3
|
-
Initial alpha release, still tied to a rails application config. There are no test, and some tight coupling deep in the code.
|
3
|
+
Initial alpha release, still tied to a rails application config. There are no test, and some tight coupling deep in the code. This is an internal tool in the early stages
|
4
|
+
of open source
|
4
5
|
Hopefully this should be improved in later releases.
|
5
6
|
|
6
7
|
|
@@ -15,6 +16,17 @@ Add `config/initializers/mongo_logger.rb`
|
|
15
16
|
app_config = Rails.application.config
|
16
17
|
Mog = WinstonMongodbRails::MongoLogger.create_logger(app_config, ((app_config.paths.log.to_a rescue nil) || app_config.paths['log']).first)
|
17
18
|
|
19
|
+
|
20
|
+
For mongo configuration, you need to add the configuration of the mongodb database to `mongoid.yml` or `database.yml`
|
21
|
+
|
22
|
+
production:
|
23
|
+
username: username
|
24
|
+
password: password
|
25
|
+
database: logs
|
26
|
+
replicaset: ['10.10.10.2:27017', '10.10.10.1:27017']
|
27
|
+
replicaset_name: 'replicaset_name'
|
28
|
+
|
29
|
+
|
18
30
|
## Usage
|
19
31
|
|
20
32
|
Mog.error "This is an error", object_to_inspect
|
@@ -3,19 +3,17 @@ class MongoDatabase
|
|
3
3
|
attr_reader :connection
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
|
-
|
6
|
+
|
7
|
+
options = options.symbolize_keys
|
8
|
+
|
9
|
+
|
7
10
|
if ['production', 'staging'].include? Rails.env
|
8
11
|
|
9
|
-
@connection = Mongo::ReplSetConnection.new(
|
10
|
-
@connection.add_auth(
|
11
|
-
@connection.add_auth('admin',
|
12
|
+
@connection = Mongo::ReplSetConnection.new(options[:replicaset], :read => :secondary, :name => options[:replicaset_name])
|
13
|
+
@connection.add_auth(options[:database], options[:username], options[:password])
|
14
|
+
@connection.add_auth('admin', options[:username], options[:password])
|
12
15
|
else
|
13
|
-
|
14
|
-
# url = "mongodb://#{APP_CONFIG['username']}:#{APP_CONFIG['password']}@#{APP_CONFIG['host']}/#{APP_CONFIG['database']}"
|
15
|
-
# else
|
16
|
-
# url = "mongodb://#{APP_CONFIG['host']}"
|
17
|
-
# end
|
18
|
-
url = "mongodb://#{APP_CONFIG['host']}"
|
16
|
+
url = "mongodb://#{options[:host]}"
|
19
17
|
@connection = Mongo::Connection.from_uri(url)
|
20
18
|
end
|
21
19
|
|
@@ -4,7 +4,7 @@ module WinstonMongodbRails
|
|
4
4
|
# Aim to rely on the mongodb driver for replicaset chat.
|
5
5
|
|
6
6
|
# Looks for configuration files in this order
|
7
|
-
CONFIGURATION_FILES = ["mongoid.yml", "database.yml"]
|
7
|
+
CONFIGURATION_FILES = ["mongo_logger.yml", "mongoid.yml", "database.yml"]
|
8
8
|
LOG_LEVEL_SYM = [:debug, :info, :warn, :error, :fatal, :unknown]
|
9
9
|
|
10
10
|
def initialize(options={})
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.description = "This allows many applications to log to a shared mongodb logger. It is useful, if you have many small applications / load balanced applications and you want to treat a log as a first class citizen."
|
17
17
|
|
18
18
|
s.add_dependency('mongo')
|
19
|
+
s.add_dependency('bson_ext')
|
19
20
|
|
20
21
|
s.required_rubygems_version = ">= 1.3.1"
|
21
22
|
s.require_path = 'lib'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winston_mongodb_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alastair Brunton
|
@@ -32,6 +32,20 @@ dependencies:
|
|
32
32
|
version: "0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bson_ext
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
description: This allows many applications to log to a shared mongodb logger. It is useful, if you have many small applications / load balanced applications and you want to treat a log as a first class citizen.
|
36
50
|
email:
|
37
51
|
- info@simplyexcited.co.uk
|