-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added configuration module and tied logging parameters into it
- Loading branch information
Showing
7 changed files
with
155 additions
and
142 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 |
---|---|---|
|
@@ -2,3 +2,5 @@ source 'https://rubygems.org' | |
|
||
# Specify your gem's dependencies in ekm-meter.gemspec | ||
gemspec | ||
|
||
|
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
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 |
---|---|---|
@@ -1,23 +1,55 @@ | ||
module EkmOmnimeter | ||
|
||
# Module level access to configuration | ||
class << self | ||
attr_writer :configuration | ||
end | ||
|
||
# Lazy initialization of default config | ||
def self.configuration | ||
@configuration ||= Configuration.new | ||
end | ||
|
||
# Reset configuration | ||
def self.reset | ||
@configuration = Configuration.new | ||
end | ||
|
||
# Allow block style configuration | ||
def self.configure | ||
yield(configuration) | ||
end | ||
|
||
# Define the configuration options | ||
class Configuration | ||
attr_accessor :sockets | ||
|
||
attr_accessor :log_level # :off, :all, :debug, :info, :warn, :error, :fatal | ||
attr_accessor :trace_exceptions # Default is true | ||
attr_accessor :log_to_stdout # Default is true | ||
attr_accessor :stdout_colors # Default is :for_dark_backgroundm, :for_light_background, or custom by passing a hash that conforms to https://github.com/TwP/logging/blob/master/examples/colorization.rb | ||
attr_accessor :log_file # Default is nil | ||
attr_accessor :log_file_layout # :basic, :json, :yaml, or a pattern such as '[%d] %-5l: %m\n' | ||
attr_accessor :rolling_log_file_age # Default is false, options are false or 'daily', 'weekly', 'monthly' or an integer | ||
attr_accessor :rolling_log_limit # Default is false, but any positive integer can be passed | ||
attr_accessor :growl_on_error # Default is false | ||
|
||
# Specify the configuration defaults and support configuration via hash .onfiguration.new(config_hash) | ||
def initialize(options={}) | ||
|
||
log_level = options[:log_level] || :off | ||
trace_exceptions = options[:trace_exceptions] || true | ||
log_to_stdout = options[:log_to_stdout] || true | ||
stdout_colors = options[:stdout_colors] || :for_dark_background | ||
log_file = options[:log_file] || nil | ||
log_file_layout = options[:log_file_layout] || :basic | ||
rolling_log_file_age = options[:rolling_log_file_age] || false | ||
rolling_log_limit = options[:rolling_log_limit] || false | ||
growl_on_error = options[:growl_on_error] || false | ||
|
||
end | ||
|
||
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.