LoginSignup
0
0

CodeIgniter3をビルトインサーバーで起動したときにサーバーログにメッセージを表示する方法

Posted at

※CodeIgniter3は新規案件で採用しないほうがいいです。

適当なhelperファイルに以下の関数を追加しておき、ログを吐き出したいところで呼び出す。

/**
 * Write message to server log. Easy debugging!!
 *
 * @param mixed $message
 * @return void
 */
function server_log($message)
{
    if (!is_string($message)) {
        $message = var_export($message, true);
    }
    $date = date("Y-m-d H:i:s");
    file_put_contents("php://stdout", "[$date] $message" . PHP_EOL);
}
0
0
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
0
0