Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved configuration logic into its own class
- Loading branch information
Showing
4 changed files
with
190 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
module Bunyan | ||
class Logger | ||
|
||
class Config | ||
# used to hold all user-defined configuration options | ||
attr_accessor :collection, :database, :disabled | ||
|
||
def initialize | ||
@size = 52428800 | ||
@disabled = false | ||
end | ||
|
||
def [](meth) | ||
send(meth) | ||
end | ||
|
||
# First time called sets the database name. | ||
# Otherwise, returns the database name. | ||
def database(db_name = nil) | ||
@database ||= db_name | ||
end | ||
alias_method :database=, :database | ||
|
||
# First time called sets the collection name. | ||
# Otherwise, returns the collection name. | ||
# For the actual collection object returned by Mongo, see #db. | ||
def collection(coll = nil) | ||
@collection ||= coll | ||
end | ||
alias_method :collection=, :collection | ||
|
||
def disabled(dis = nil) | ||
@disabled ||= dis | ||
end | ||
alias_method :disabled=, :disabled | ||
|
||
# default size is 50 megabytes | ||
def size(new_size = nil) | ||
new_size.nil? ? @size : @size = new_size | ||
end | ||
alias_method :size=, :size | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.