phalcon/cphalcon · error · Phalcon\Logger\Adapter\Exceptions\InvalidStreamMode

Adapter cannot be opened in read mode

Error message

Adapter cannot be opened in read mode

What it means

Thrown by the Stream logger adapter constructor when the 'mode' option contains 'r' (read mode). The logger only appends/writes; opening the log file for reading is rejected. Use a write/append mode such as 'ab'.

Solutions

  1. Use a write mode such as 'ab' (default) or 'wb' in the adapter options
  2. Remove accidental 'r' modes copied from file-reading code
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Logger/Adapter/Stream.zep:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/d5e9dc836875689c. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Logger/Adapter/Stream.zep:73

     * Stream name
     */
    protected string name;

    /**
     * Stream constructor.
     *
     * @throws InvalidStreamMode
     */
    public function __construct(string name, array options = [])
    {
        var mode;

        /**
         * Mode
         */
        let mode = true === isset(options["mode"]) ? options["mode"] : "ab";
        if (false !== mb_strpos(mode, "r")) {
            throw new InvalidStreamMode();
        }

        let this->name = name,
            this->mode = mode;
    }

    /**
     * Closes the stream
     */
    public function close() -> bool
    {
        var handler;

        if (this->handler !== null) {
            let handler = this->handler,
                this->handler = null;
            return this->phpFclose(handler);
        }

View on GitHub (pinned to b7419de9cd)