在默认的sinatra webserver webrick中,在开发模式下,我可以在stdout中得到以下内容:
127.0.0.1 - - [23/May/2017:19:23:10 CST] "GET / HTTP/1.1" 200 4
- -> /
但是当我
set :server, "thin"
没有显示请求信息,如何打开它?我希望显示精简登录代码,而不是thin --debug
cli
更新
这里是完整代码:
require 'sinatra/base'
class App < Sinatra::Base
set :server, "thin"
get '/' do
"hello world"
end
get "/hello" do
"drlow elloh"
end
end
App.run!
答案 0 :(得分:1)
如果您没有更改任何配置,则与瘦无关。请添加主应用程序文件,sinatra,瘦和机架版本。
示例强>
2分钟的集会
$ mkdir thiny
$ nano thiny/app.rb
$ cd thiny/
$ ruby app.rb
以下行是打印到std输出的日志,我相信你正在寻找。
== Sinatra (v2.0.0) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
127.0.0.1 - - [23/May/2017:16:04:08 +0400] "GET / HTTP/1.1" 200 11 0.0111
127.0.0.1 - - [23/May/2017:16:04:17 +0400] "GET /hello HTTP/1.1" 200 11 0.0006
127.0.0.1 - - [23/May/2017:16:04:18 +0400] "GET /hello HTTP/1.1" 200 11 0.0011
127.0.0.1 - - [23/May/2017:16:04:19 +0400] "GET /hello HTTP/1.1" 200 11 0.0007
app.rb的内容
require 'sinatra'
set :server, "thin"
get '/' do
"hello world"
end
get "/hello" do
"drlow elloh"
end
答案 1 :(得分:1)
我找到了解决方案,只需添加set :logging, true
,这里是正确的代码:
require 'sinatra/base'
class App < Sinatra::Base
set :server, "thin"
set :logging, true
get '/' do
"hello world"
end
get "/hello" do
"drlow elloh"
end
end
App.run!