private function writeLine(string $str)
    {
        $now = time();
        if ($this->file && $this->file_opened < $now - $this->reopen_interval)
        {
            // Close the file after a set interval
            fclose($this->file);
            $this->file = null;
        }

        if (!$this->file)
        {
            touch($this->filename);
            try
            {
                Hook::execute("Wedeto.IO.FileCreated", ['path' => $this->filename]);
            }
            // @codeCoverageIgnoreStart
            // Ignore recursion: if and error occurs in a hook it may end up
            // calling the file writer again, resulting in a loop.
            catch (RecursionException $e)
            {} 
            // @codeCoverageIgnoreEnd


            $this->file = fopen($this->filename, 'a');
            $this->file_opened = time();
        }

        if ($this->file)
            fwrite($this->file, $str . "\n");
    }
private function writeLine(string $str)
    {
        $now = time();
        if ($this->file && $this->file_opened < $now - $this->reopen_interval)
        {
            // Close the file after a set interval
            fclose($this->file);
            $this->file = null;
        }

        if (!$this->file)
        {
            touch($this->filename);
            try
            {
                Hook::execute("Wedeto.IO.FileCreated", ['path' => $this->filename]);
            }
            // @codeCoverageIgnoreStart
            // Ignore recursion: if and error occurs in a hook it may end up
            // calling the file writer again, resulting in a loop.
            catch (RecursionException $e)
            {} 
            // @codeCoverageIgnoreEnd


            $this->file = fopen($this->filename, 'a');
            $this->file_opened = time();
        }

        if ($this->file)
            fwrite($this->file, $str . "\n");
    }
private function writeLine ( string $ str ) { $ now = time ( ) ; if ( $ this -> file && $ this -> file_opened < $ now - $ this -> reopen_interval ) { // Close the file after a set interval fclose ( $ this -> file ) ; $ this -> file = null ; } if ( ! $ this -> file ) { touch ( $ this -> filename ) ; try { Hook :: execute ( "Wedeto.IO.FileCreated" , [ 'path' => $ this -> filename ] ) ; } // @codeCoverageIgnoreStart // Ignore recursion: if and error occurs in a hook it may end up // calling the file writer again, resulting in a loop. catch ( RecursionException $ e ) { } // @codeCoverageIgnoreEnd $ this -> file = fopen ( $ this -> filename , 'a' ) ; $ this -> file_opened = time ( ) ; } if ( $ this -> file ) fwrite ( $ this -> file , $ str . "\n" ) ; }
Write a line to the log file
@param string $str The line to write
Write a line to the log file