From: František Dvořák Date: Thu, 9 Jun 2016 12:37:38 +0000 (+0200) Subject: Sync sinatra logger with global logger, the chaos with logging probably must remain... X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=1aa8b132527c0ce54ba677c71a794db7355f0867;p=now.git Sync sinatra logger with global logger, the chaos with logging probably must remain though. --- diff --git a/config.ru b/config.ru index c7ba665..91048e8 100644 --- a/config.ru +++ b/config.ru @@ -9,5 +9,9 @@ require './lib/nebula.rb' require './lib/api.rb' $logger = Logger.new(STDOUT) +$logger.formatter = proc do |severity, datetime, progname, msg| + date_format = datetime.strftime("%Y-%m-%dT%H:%M:%S%z") + sprintf "[#{date_format}] %5s: #{msg}\n", severity +end $nebula = Now::Nebula.new() run Now::Application diff --git a/lib/api.rb b/lib/api.rb index ead98eb..9396775 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -14,6 +14,16 @@ module Now @nebula = $nebula end + configure do + enable :logging, :dump_errors + set :raise_errors, true + end + + before do + # to sinatra request logger point to proper object + env['rack.logger'] = $logger + end + get '/' do cross_origin API_VERSION