diff --git a/jls/net/http/filter/LogHttpFilter.lua b/jls/net/http/filter/LogHttpFilter.lua index c3fa1f1..931e37d 100644 --- a/jls/net/http/filter/LogHttpFilter.lua +++ b/jls/net/http/filter/LogHttpFilter.lua @@ -6,25 +6,22 @@ After adding this filter, any request containing the header *jls-logger-level* w @pragma nostrip ]] -local logger = require('jls.lang.logger'):get(...) +local rootLogger = require('jls.lang.logger') --- A LogHttpFilter class. -- @type LogHttpFilter return require('jls.lang.class').create('jls.net.http.HttpFilter', function(filter) function filter:doFilter(exchange) - local ml = exchange:getRequest():getHeader('jls-logger-level') - if ml then - ml = logger:getClass().levelFromString(ml) - if ml then - local level = logger:getLevel() - if ml < level then - logger:setLevel(ml) - exchange:onClose():next(function() - logger:setLevel(level) - end) - end - end + local ll = exchange:getRequest():getHeader('jls-logger-level') + if ll then + local config = rootLogger:getConfig() + rootLogger:cleanConfig() + rootLogger:applyConfig(ll) + exchange:onClose():next(function() + rootLogger:cleanConfig() + rootLogger:applyConfig(config) + end) end end