Tei*_*ion 1 elixir phoenix-framework
以前我一直在使用表来记录我的系统中的使用情况和页面浏览量.我现在正在凤凰城写一个系统,试图找出如何最好地跟踪使用情况.
目前我正在使用插头插入日志.但是,我无法跟踪页面生成时间,因为在页面生成过程开始时调用了插件,我无法在最后找到如何调用它.
有没有办法做到这一点,甚至更好的解决方案,我在谷歌搜索中找不到?
但是,我无法跟踪页面生成时间,因为在页面生成过程开始时调用了插件,我无法在最后找到如何调用它.
您可以使用Plug.Conn.register_before_send/2来执行fn生成后的页面和发送响应之前.Plug.Logger 使用相同的方式来显示响应请求所花费的时间.
def call(conn, level) do
# Executed before the request is processed.
Conn.register_before_send(conn, fn conn ->
# Executed after the response is generated.
conn # Make sure to return the `conn` here.
end)
end
Run Code Online (Sandbox Code Playgroud)