lib/hanami/logger.rb in hanami-utils-1.1.0.beta1 vs lib/hanami/logger.rb in hanami-utils-1.1.0.beta2

- old
+ new

@@ -3,10 +3,11 @@ require 'logger' require 'hanami/utils/string' require 'hanami/utils/json' require 'hanami/utils/hash' require 'hanami/utils/class_attribute' +require 'hanami/utils/files' module Hanami # Hanami logger # # Implement with the same interface of Ruby std lib `Logger`. @@ -109,11 +110,11 @@ # @api private NEW_LINE = $/ # @since 1.0.0 # @api private - RESERVED_KEYS = %i(app severity time).freeze + RESERVED_KEYS = %i[app severity time].freeze include Utils::ClassAttribute class_attribute :subclasses self.subclasses = Set.new @@ -451,10 +452,17 @@ # # logger = Hanami::Logger.new(formatter: :json) # logger.info "Hello World" # # # => {"app":"Hanami","severity":"DEBUG","time":"2017-03-30T13:57:59Z","message":"Hello World"} - def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: []) # rubocop:disable Metrics/ParameterLists + # rubocop:disable Lint/HandleExceptions + # rubocop:disable Metrics/ParameterLists + def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil, filter: []) + begin + Utils::Files.mkdir_p(stream) + rescue TypeError + end + super(stream, *args) @level = _level(level) @stream = stream @application_name = application_name