We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

\Phalcon\Logger\Adapter\File options

File adapter constructor accepts the second argument and expect to receive an array of options:

/**
 * \Phalcon\Logger\Adapter\File constructor
 *
 * @param string $name
 * @param array $options
 */
public function __construct($name, $options=null){
}

What they are? Is there any way to flush the log file before each time the adapter is created?



1.2k
Accepted
answer

The only option (so far) is 'mode' — this is file open mode (ie, "a", "w") which is passed to fopen(); if 'mode' is not supplied, 'ab' is used by default.

As for flushing — do you mean to flush the data after every fwrite() to the log file?

Thanks!

As for flushing — do you mean to flush the data after every fwrite() to the log file? It was miss print, I meant truncate!

Just pass array('mode' => 'w') in $options.