Sync sinatra logger with global logger, the chaos with logging probably must remain...
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 9 Jun 2016 12:37:38 +0000 (14:37 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 9 Jun 2016 12:37:38 +0000 (14:37 +0200)
config.ru
lib/api.rb

index c7ba665..91048e8 100644 (file)
--- 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
index ead98eb..9396775 100644 (file)
@@ -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