Sha256: df51caf4c4915d24ccc2ffd2bd2a5f0e274fb727b02c34b80a8ccb258b839fbc
Contents?: true
Size: 1.26 KB
Versions: 14
Compression:
Stored size: 1.26 KB
Contents
require 'mongo' require 'erb' require 'active_support' require 'active_support/core_ext' module MongodbLogger class ServerConfig class << self def set_config(config_path) if File.file?(config_path) config_file = File.new(config_path) config = YAML.load(ERB.new(config_file.read).result) else raise "Config file not found" end @db_configuration = { 'host' => 'localhost', 'port' => 27017}.merge(config) @db_configuration["collection"] ||= "production_log" @db = Mongo::Connection.new(@db_configuration['host'], @db_configuration['port'], :auto_reconnect => true).db(@db_configuration['database']) if @db_configuration['username'] && @db_configuration['password'] @authenticated = @db.authenticate(@db_configuration['username'], @db_configuration['password']) end @collection = @db[@db_configuration["collection"]] end def get_config @db_configuration end def db @db end def collection @collection end end end end
Version data entries
14 entries across 14 versions & 1 rubygems