• Server log lines say "!ERROR" but are logged below error severity

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Sun Nov 22 02:09:56 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1396
    2026-11-22 02:09:56 -0800

    Many server log lines carry an `!ERROR` prefix but are logged at a severity below `LOG_ERR`. The text says "error"; the severity says "warning" (or less). Only the severity has consequences, so the two disagree about whether anything is wrong.

    ## Why the severity is what counts

    Each server's `lprintf()` treats `level <= LOG_ERR` specially: the line is written to `data/error.log` via `errorlog()`, the error counter is incremented, and the `errormsg` callback (sbbsctrl's error indicator) fires. A line logged at `LOG_WARNING` or lower does none of that, whatever its text says.

    | File | `level <= LOG_ERR` check at line |
    |---|---|
    | `ftpsrvr.cpp` | 141 |
    | `mailsrvr.cpp` | 220 |
    | `websrvr.cpp` | 589 |
    | `services.cpp` | 133 |
    | `main.cpp` | 261, 287 |

    The effects of the mismatch:

    - An `!ERROR` line at warning level never reaches `error.log` and is not counted as an error.
    - Filtering the log by level and grepping it for `!ERROR` give different counts of errors.
    - A sysop reading the line cannot tell whether it needs attention.

    ## How common it is

    `lprintf()` calls whose format string begins a message with `!ERROR`, by the severity passed, as of afa9dc33f5 (2026-11-22):

    | File | CRIT | ERR | WARNING | NOTICE | INFO/DEBUG |
    |---|---|---|---|---|---|
    | `ftpsrvr.cpp` | 0 | 0 | 12 | 1 | 0 |
    | `mailsrvr.cpp` | 3 | 2 | 12 | 1 | 0 |
    | `websrvr.cpp` | 0 | 8 | 6 | 1 | 3 |
    | `services.cpp` | 2 | 6 | 5 | 0 | 0 |
    | `main.cpp` | 5 | 14 | 4 | 0 | 0 |
    | **Total** | 10 | 30 | 39 | 3 | 3 |

    So 45 of 85 are below `LOG_ERR`. The counts come from:

    ```
    grep -c 'lprintf(LOG_<LEVEL>, "[^"]*!ERROR' <file>
    ```

    They cover direct `lprintf()` calls with the level and string on one line only. `errprintf(LOG_ERR, ...)` calls, calls that pass the level in a variable, and other `!`-prefixed text (`!DATA ERROR`, `!JavaScript`, `!TIMEOUT`, ...) are not counted, and the other servers and utilities were not surveyed.

    ## Examples

    Mostly socket-level and client-caused failures:

    ```
    ftpsrvr.cpp:354 LOG_WARNING "%04d !ERROR %d closing socket from line %u" ftpsrvr.cpp:437 LOG_WARNING "%04d !ERROR %d sending"
    ftpsrvr.cpp:440 LOG_WARNING "%04d !ERROR: short send: %u instead of %u" ftpsrvr.cpp:459 LOG_NOTICE "%04d !ERROR %d receiving on socket (line %u)" mailsrvr.cpp:512 LOG_NOTICE "%04d %-5s !ERROR %d sending on socket" mailsrvr.cpp:1019 LOG_WARNING "%04u %s !ERROR %d (%s) removing %s" websrvr.cpp:809 LOG_WARNING "%04d %-5s [%s] !ERROR %d sending on socket" websrvr.cpp:1687 LOG_WARNING "%04d !ERROR %d opening %s"
    services.cpp:2388 LOG_WARNING "0000 !ERROR %d polling sockets: %s" main.cpp:2427 LOG_WARNING "Node %d !ERROR %d receiving from socket %d" ```

    The same event is also labeled inconsistently between servers: `!ERROR %d sending on socket` is `LOG_NOTICE` in the mail server and `LOG_WARNING` in the web server.

    ## What prompted this

    The FTP server logs this about 70 times a day on vert, once per upload from a camera that drops its FTPS control connection without closing the TLS session:

    ```
    4244 !ERROR: recv on socket returned unexpected value: -42 (line 565)
    ```

    `-42` is `CRYPT_ERROR_WRITE`. It is logged at `LOG_WARNING`, so it is absent from `error.log`, yet it reads as an error in the server log.

    ## Suggested rule

    Make the text and the level agree, one line at a time:

    - If the sysop should act on it, or it belongs in `error.log`: log at `LOG_ERR` (or higher) and keep `!ERROR`.
    - If it is a misbehaving client or a routine network failure: keep the lower level and drop `ERROR` from the text (e.g. "send failed", "connection lost").

    Most of the 45 look like the second kind. Rewording them changes strings that sysops and log-watching scripts may match on, so that is a compatibility consideration for the release notes.

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Sun Nov 22 02:21:20 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1396#note_11254

    A refinement of the "Suggested rule" in the description, which was stricter than it needs to be.

    The problem is the `!ERROR` marker, not the word "error":

    - **`!ERROR` marker ⇒ `LOG_ERR` or higher.** A line the sysop should act on. - **Below `LOG_ERR` ⇒ no `!ERROR` marker.** The plain word is fine as description, e.g. "TLS connection lost on receive (cryptlib write error, line 569)" at notice level. The marker is what claims a severity the line does not have.
    - **Exception: a level decided at run time.** `errprintf()` demotes a repeat of the same error to `LOG_WARNING` (`repeated_error()`, keyed on line and function), so its `!ERROR` text is sometimes logged at warning level by design. That is fine. A fixed `lprintf(LOG_WARNING, "... !ERROR ...")` is the case to fix.

    The table in the description counts only fixed-level `lprintf()` calls, so the 45 lines below `LOG_ERR` are all of the kind to fix; none are `errprintf()` demotions.

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)