LoginSignup
1
1

More than 5 years have passed since last update.

Ethnaで、Action名とView名をaccesslogに記録する方法

Posted at

Action名、View名をWebサーバのログに記録しておくといろいろ捗ります。

やり方

ViewClassで下記のようにsetPropしておいて、

lib/Ethna/class/ViewClass.php
protected function _setDefault($renderer)
{
...
        $renderer->setProp('actionname', $this->backend->getActionClass()->getActionName() );
        $renderer->setProp('viewname', $this->forward_name);
}

Renderer/Smartyで

lib/Ethna/class/Renderer/Smarty.php
                     $captured = $this->engine->fetch($this->template);
                     return $captured;
                 } else {
+                    header('X-MemoryUsage: ' .  memory_get_usage());
+                    header('X-ActionName: ' . strtolower($this->getProp('actionname')));
+                    header('X-ViewName: ' . strtolower($this->getProp('viewname')));
                     $this->engine->display($this->template);
                 }

あとはhttpd.confで

httpd.conf
LogFormat "time:%t\thost:%h\tident:%l\tuser:%u\treq:%r\tstatus:%>s\tsize:%b\treferer:%{Referer}i\tua:%{User-Agent}i\taction:%{X-ActionName}o\tview:%{X-ViewName}o" ltsv

てな感じです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1