Class: TidyLogger
- Inherits:
-
Logger
- Object
- Logger
- TidyLogger
- Defined in:
- lib/tidy_logger.rb
Defined Under Namespace
Classes: Formatter
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Method Summary collapse
- #config(options = :time_and_level) ⇒ Object
-
#initialize(*args) ⇒ TidyLogger
constructor
A new instance of TidyLogger.
Constructor Details
#initialize(*args) ⇒ TidyLogger
Returns a new instance of TidyLogger.
4 5 6 7 |
# File 'lib/tidy_logger.rb', line 4 def initialize(*args) super @formatter = Formatter.new end |
Instance Method Details
#config(options = :time_and_level) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tidy_logger.rb', line 9 def config( = :time_and_level) case when Symbol = { type: } when Hash [:type] = :time_and_level if [:type].nil? [:type] = :title if [:title] when Proc = { type: } else raise Error, "invalid options: #{.inspect}" end self.formatter.type = [:type] self.level = [:level] || Logger::INFO self.formatter.datetime_format = [:datetime_format] || '%Y-%m-%dT%H:%M:%S' self.formatter.title = [:title] self end |