feat(libc): implement syslog and vsyslog #1729

Merged
johnmaia merged 2 commits from upstream-pr/1729 into main 2026-10-09 21:48:33 +00:00
johnmaia commented 2026-10-08 17:47:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T17:47:03Z.


What

Implements syslog (NID s-e0hFe21FA) and vsyslog (NID rzvf5zicF88) in libc. Two of the homebrew titles in #1578 import syslog from libSceLibcInternal, which resolves through libc: ps5-opengl (PPSA99005) and ProsperoRadio (PPSA99001).

  • Output: each message is written to stderr as [syslog:<priority>] <message>, under a lock and flushed, with a newline added when the message has none. This is the same convention sceKernelDebugOutText uses ([debug:<channel>]).
  • Format and priority follow FreeBSD's vsyslog:
    • %m expands to the guest errno's message (FreeBSD numbering via strerror_r), with any % in it doubled, and %%m stays a literal %m.
    • Bits outside LOG_PRIMASK | LOG_FACMASK produce syslog: unknown facility/priority: <hex> and are then masked off.
    • A missing facility becomes LOG_USER.
    • errno is preserved.
  • Formatting uses the same paths as vfprintf: SysV va_list on Linux and LibcDetail::FormatWindows on Windows.
  • Recorded in TechnicalDebt: messages go to stderr instead of the console's system log, and openlog, setlogmask and closelog are not implemented, so identity, options and mask are not applied. Neither title imports them.

Tested

  • New guest_syslog test, registered in ctest. It captures stderr and checks the exact output for:

    • plain formatting;
    • %m with errno 2, a literal %%m and %%;
    • unknown priority bits (0x10004, the warning line followed by the masked message);
    • the default facility;
    • an empty message.

    It also checks that errno is unchanged.

  • Linux (Ubuntu 24.04.5, GCC 13.3) and Windows 11 (WinLibs GCC 15.2.0 r7): guest_syslog, guest_errors, guest_formatting and guest_filesystem pass.

  • No title was run: both titles still have other missing imports listed in #1578.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4790693853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1729). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-08T17:47:03Z. --- ### What Implements `syslog` (NID `s-e0hFe21FA`) and `vsyslog` (NID `rzvf5zicF88`) in libc. Two of the homebrew titles in #1578 import `syslog` from libSceLibcInternal, which resolves through libc: ps5-opengl (PPSA99005) and ProsperoRadio (PPSA99001). - Output: each message is written to `stderr` as `[syslog:<priority>] <message>`, under a lock and flushed, with a newline added when the message has none. This is the same convention `sceKernelDebugOutText` uses (`[debug:<channel>]`). - Format and priority follow FreeBSD's `vsyslog`: - `%m` expands to the guest errno's message (FreeBSD numbering via `strerror_r`), with any `%` in it doubled, and `%%m` stays a literal `%m`. - Bits outside `LOG_PRIMASK | LOG_FACMASK` produce `syslog: unknown facility/priority: <hex>` and are then masked off. - A missing facility becomes `LOG_USER`. - errno is preserved. - Formatting uses the same paths as `vfprintf`: SysV `va_list` on Linux and `LibcDetail::FormatWindows` on Windows. - Recorded in TechnicalDebt: messages go to `stderr` instead of the console's system log, and `openlog`, `setlogmask` and `closelog` are not implemented, so identity, options and mask are not applied. Neither title imports them. ### Tested - New `guest_syslog` test, registered in ctest. It captures `stderr` and checks the exact output for: - plain formatting; - `%m` with errno 2, a literal `%%m` and `%%`; - unknown priority bits (`0x10004`, the warning line followed by the masked message); - the default facility; - an empty message. It also checks that errno is unchanged. - Linux (Ubuntu 24.04.5, GCC 13.3) and Windows 11 (WinLibs GCC 15.2.0 r7): `guest_syslog`, `guest_errors`, `guest_formatting` and `guest_filesystem` pass. - No title was run: both titles still have other missing imports listed in #1578. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-08 17:47:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T17:47:31Z.


Progress report (54f28f2 → 9d1ac90)

📈 System libraries: 85.31% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc syslog_nid_postfix
libc vsyslog_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6065752259 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1729#issuecomment-6065752259). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T17:47:31Z. --- <!-- progress-report --> ### Progress report (54f28f2 → 9d1ac90) 📈 **System libraries**: 85.31% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `syslog_nid_postfix` | | libc | `vsyslog_nid_postfix` | </details>
github-actions[bot] commented 2026-10-08 17:50:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T17:50:46Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1727 __error_nid_postfix
#1738 __error_nid_postfix
#1772 __error_nid_postfix
#1831 docs/dev/TechnicalDebt.md L362
#1860 __error_nid_postfix
#2051 __error_nid_postfix
#2057 core/libs/prx/libc/CMakeLists.txt L235
#2123 __error_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6065805586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1729#issuecomment-6065805586). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T17:50:46Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1727 | | `__error_nid_postfix` | | | #1738 | | `__error_nid_postfix` | | | #1772 | | `__error_nid_postfix` | | | #1831 | `docs/dev/TechnicalDebt.md` [L362](https://github.com/boykopovar/AnyPS5/blob/3bd74c155db06c4dba07441b28f570121475b9b1/docs/dev/TechnicalDebt.md#L362) | | | | #1860 | | `__error_nid_postfix` | | | #2051 | | `__error_nid_postfix` | | | #2057 | `core/libs/prx/libc/CMakeLists.txt` [L235](https://github.com/boykopovar/AnyPS5/blob/3bd74c155db06c4dba07441b28f570121475b9b1/core/libs/prx/libc/CMakeLists.txt#L235) | | | | #2123 | | `__error_nid_postfix` | |
adriadam10 commented 2026-10-09 21:29:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:29:00Z.


Checked build + full ctest on Linux (guest_syslog passes and fails without the change), and %m/%%/facility handling against FreeBSD lib/libc/gen/syslog.c; the Windows relinker failure is the runner's clang lacking the amdgcn target, unrelated to this PR.

One fix added as a separate commit on your branch:

  • FreeBSD reports the "unknown facility/priority" complaint through syslog(LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID, ...), so the priority it logs is 0x23, not 3. Syslog.cpp, the test expectation ([syslog:35]) and the TechnicalDebt line now say so.

Not verified here: Windows runtime of the formatting path and any title. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089563501 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1729#issuecomment-6089563501). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:29:00Z. --- Checked build + full ctest on Linux (`guest_syslog` passes and fails without the change), and `%m`/`%%`/facility handling against FreeBSD `lib/libc/gen/syslog.c`; the Windows relinker failure is the runner's clang lacking the amdgcn target, unrelated to this PR. One fix added as a separate commit on your branch: - FreeBSD reports the "unknown facility/priority" complaint through `syslog(LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID, ...)`, so the priority it logs is `0x23`, not `3`. `Syslog.cpp`, the test expectation (`[syslog:35]`) and the TechnicalDebt line now say so. Not verified here: Windows runtime of the formatting path and any title. Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1729
No description provided.