我该如何控制这些多个记录器?

时间:2019-03-24 10:41:11

标签: logging sinatra

在Sinatra程序中,我这样设置(唯一的一个?)记录器:

  configure do
    set :root, File.dirname(__dir__)
    enable :sessions
    set :session_secret, ENV.fetch('SESSION_SECRET') { SecureRandom.hex(64) }
    use Rack::Flash

    enable :logging
    file = File.open("#{root}/log/#{environment}.log", 'a+')
    file.sync = true
    logger = Logger.new(file)
    logger.level = Logger::DEBUG if development?
    ActiveRecord::Base.logger = logger
    logger.info("NtConfig Configure Block.")
    set :logger, logger
    NtState.logger = logger
  end

我的日志输出显示了三个不同记录器的证据,但是我不知道其他两个记录器是谁或哪里:

10:44:24 PM web.1 |  [46799] * Listening on tcp://0.0.0.0:9292
10:44:24 PM web.1 |  [46799] ! WARNING: Detected 3 Thread(s) started in app boot:
10:44:24 PM web.1 |  [46799] ! #<Thread:0x00007f8de6b66798@/Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep'
10:44:24 PM web.1 |  [46799] ! #<Thread:0x00007f8de75aefc0@/Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/bunny-2.14.1/lib/bunny/heartbeat_sender.rb:46 sleep> - /Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/bunny-2.14.1/lib/bunny/heartbeat_sender.rb:51:in `sleep'
10:44:24 PM web.1 |  [46799] ! #<Thread:0x00007f8de75aee08@/Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/bunny-2.14.1/lib/bunny/reader_loop.rb:35 sleep> - /Users/pitosalas/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/bunny-2.14.1/lib/bunny/cruby/socket.rb:62:in `select'
10:44:24 PM web.1 |  [46799] Use Ctrl-C to stop
10:44:24 PM web.1 |  [46799] - Worker 0 (pid: 46813) booted, phase: 0
10:44:36 PM web.1 |  127.0.0.1 - - [23/Mar/2019:22:44:36 -0400] "GET / HTTP/1.1" 200 3284 0.0387
10:44:41 PM web.1 |  127.0.0.1 - - [23/Mar/2019:22:44:41 -0400] "GET / HTTP/1.1" 200 3284 0.0058
10:44:44 PM web.1 |  127.0.0.1 - - [23/Mar/2019:22:44:44 -0400] "GET /login HTTP/1.1" 200 3437 0.0035
10:44:53 PM web.1 |  I, [2019-03-23T22:44:53.995438 #46813]  INFO -- : user: {"email"=>"testuser@sample.com", "password"=>"password"}
10:44:55 PM web.1 |  127.0.0.1 - - [23/Mar/2019:22:44:55 -0400] "POST /login HTTP/1.1" 303 - 1.1000
10:44:55 PM web.1 |  I, [2019-03-23T22:44:55.133446 #46813]  INFO -- : Logged in user

0 个答案:

没有答案