| name | logging-error-code-audit |
| description | Audit the `radio_fivem` Lua resource for `errorLog`/`logError` and `warnLog`/`logWarn` calls that are missing registered structured error or warning codes. Use when Codex needs to scan logging callsites, add new code keys to `lua/sh_logcodes.lua`, update the local `errors.md` registry, or compare the repo registry against an external documentation page of error codes. |
Logging Error Code Audit
Use the bundled scanner first. Do not hand-audit the repo unless the scanner output is obviously wrong.
Workflow
- Run
scripts/audit_log_codes.py <repo-root>.
- Review every finding grouped by file and logging function.
- For each real issue:
- add a stable key to
WarningCodes or ErrorCodes in lua/sh_logcodes.lua
- prefer the existing namespace style such as
ERR_* and WRN_*
- reuse an existing key when multiple callsites describe the same support issue
- Patch the Lua callsites so the first argument is the new or existing code key.
- Update the repo-level
errors.md so every new key has:
- code
- internal key
- meaning
- first troubleshooting step
- If an external docs page also needs validation, compare the local
errors.md codes against that page after the source-of-truth changes are complete.
Conventions
- Treat
warnLog as valid when it uses either a warning key or an error key.
- Treat
errorLog and logError as valid only when they use a registered error key.
- A raw string message as the first argument is not a code, even if it looks descriptive.
- A variable first argument is suspect unless the code path is clearly passing a preformatted coded message.
Script
Run:
python .codex/skills/logging-error-code-audit/scripts/audit_log_codes.py <repo-root>
Useful flags:
python .codex/skills/logging-error-code-audit/scripts/audit_log_codes.py <repo-root> --format json
python .codex/skills/logging-error-code-audit/scripts/audit_log_codes.py <repo-root> --include "submodules/**/*.lua"
python .codex/skills/logging-error-code-audit/scripts/audit_log_codes.py <repo-root> --logging-file "lua/sh_logcodes.lua"
Output Interpretation
raw_message_literal: first argument is a quoted message, not a registered key.
raw_expression: first argument is an expression, concatenation, format call, or variable.
unknown_code_key: first argument is a quoted identifier, but it is not registered in lua/sh_logcodes.lua.
Fix unknown_code_key by either registering the key or correcting the typo. Fix the other two by introducing or reusing a proper code key and moving the human message into the second argument.