(MAINT) Add optional API Request Logging

This was partially an exercise to use middleware, but also to enable
basic logging for the API by logging all the API calls to the logger.
This commit is contained in:
John O'Connor 2020-06-26 20:49:17 +01:00
parent a21d8c5642
commit 85ff3f7022
17 changed files with 85 additions and 24 deletions

View file

@ -9,7 +9,7 @@ module Vmpooler
# Load dashboard components
require 'vmpooler/dashboard'
def self.execute(torun, config, redis, metrics)
def self.execute(torun, config, redis, metrics, logger)
self.settings.set :config, config
self.settings.set :redis, redis unless redis.nil?
self.settings.set :metrics, metrics
@ -43,6 +43,9 @@ module Vmpooler
end
if torun.include? :api
# Enable API request logging only if required
use Vmpooler::API::RequestLogger, logger: logger if config[:config]['request_logger']
use Vmpooler::Dashboard
use Vmpooler::API::Dashboard
use Vmpooler::API::Reroute