src/includes/classes/Core/Utils/Debugging.php
protected function writeLogFileLines(string $event, array $lines): int
    {
        if (!$lines) { // No lines?
            return 0; // Stop; nothing to do here.
        }
        $this->prepareLogsDir(); // Prepares (and secures).

        if (mb_strpos($event, '#') !== false) {
            $file_name = mb_strstr($event, '#');
            $file_name = $this->c::nameToSlug($file_name);
            $file_name .= '.log'; // Add extension now.
        }
        $file_name    = $file_name ?: 'debug.log';
        $process_file = $this->logs_dir.'/process.'.$file_name;
        $file         = $this->logs_dir.'/'.$file_name;

        $this->maybeRotateLogFiles($file);

        $entry = implode("\n", $lines)."\n\n".str_repeat('-', 3)."\n\n";

        if (!isset($this->first_process_writes[$process_file])) {
            $this->first_process_writes[$process_file] = -1;
            @unlink($process_file); // First-process write.
        } // ↑ Empty file on the first write in each process.

        file_put_contents($process_file, $entry, LOCK_EX | FILE_APPEND);
        return (int) file_put_contents($file, $entry, LOCK_EX | FILE_APPEND);
    }
protected function writeLogFileLines(string $event, array $lines): int
    {
        if (!$lines) { // No lines?
            return 0; // Stop; nothing to do here.
        }
        $this->prepareLogsDir(); // Prepares (and secures).

        if (mb_strpos($event, '#') !== false) {
            $file_name = mb_strstr($event, '#');
            $file_name = $this->c::nameToSlug($file_name);
            $file_name .= '.log'; // Add extension now.
        }
        $file_name    = $file_name ?: 'debug.log';
        $process_file = $this->logs_dir.'/process.'.$file_name;
        $file         = $this->logs_dir.'/'.$file_name;

        $this->maybeRotateLogFiles($file);

        $entry = implode("\n", $lines)."\n\n".str_repeat('-', 3)."\n\n";

        if (!isset($this->first_process_writes[$process_file])) {
            $this->first_process_writes[$process_file] = -1;
            @unlink($process_file); // First-process write.
        } // ↑ Empty file on the first write in each process.

        file_put_contents($process_file, $entry, LOCK_EX | FILE_APPEND);
        return (int) file_put_contents($file, $entry, LOCK_EX | FILE_APPEND);
    }
Write lines to log file.

@since 160522 Debugging utilities.

@param string $event Event name.
@param array  $lines Log entry lines.

@return int Total number of bytes written.