lib/twiglet/logger.rb in twiglet-3.0.8 vs lib/twiglet/logger.rb in twiglet-3.1.0

- old
+ new

@@ -24,11 +24,22 @@ @level = level raise 'Service name is mandatory' \ unless service_name.is_a?(String) && !service_name.strip.empty? - formatter = Twiglet::Formatter.new(service_name, default_properties: default_properties, now: now) - super(output, formatter: formatter, level: level) + @validator = Validator.from_file('lib/twiglet/validation_schema.json') + + @formatter = Twiglet::Formatter.new( + service_name, + default_properties: default_properties, + now: now, + validator: @validator + ) + super(output, formatter: @formatter, level: level) + end + + def configure_validation_error_response(&block) + @validator.custom_error_handler = block end def error(message = nil, error = nil, &block) if error error_fields = {