openmultiplayer / openmultiplayer/open.mp
Feature request: log level support for Pawn scripts (print/printf)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 641
- Forks
- 208
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Expose log severity levels (e.g. Info / Warning / Error / Debug) to Pawn scripts, instead of the current single-level print() / printf().
Context
The core server already emits leveled log lines internally, visible in the console output, for example:
[Info] OI
[Error] Unable to start legacy network on port 7777. Port in use?
That [Info] / [Error] prefixing exists in the engine/component side, but it is not reachable from gamemode/filterscript Pawn code. From Pawn, the only natives available are print() and printf() (see omp_core.inc), which write a plain, unleveled line to both the console and log.txt. Any severity distinction today is a script-side convention (developers manually prefixing strings like "[WARNING] ..."), which is inconsistent across gamemodes and doesn't hook into anything the server already understands.
Proposal
Add Pawn-side natives that reuse the same leveled logging the engine already has, for example:
native LogInfo(const format[], {Float,_}:...);
native LogWarning(const format[], {Float,_}:...);
native LogError(const format[], {Float,_}:...);
// or a single native: native Log(LOG_LEVEL:level, const format[], {Float,_}:...);
Each would print with the same [Info] / [Warning] / [Error] prefix (and console colour, where supported) used internally, and write to log.txt the same way printf() does today.
What this would gain us
- Faster tracing/debugging: grepping
log.txtfor[Error]/[Warning]immediately isolates real problems from routine info output, instead of scrolling through everythingprintf()ever wrote. - Consistency between engine and gamemode logs: right now the server's own startup/network messages are leveled, but everything a gamemode prints is flat text, which is a visible inconsistency in the same log file.
- No more ad-hoc conventions: every gamemode currently invents its own prefix scheme (or none at all) to fake severity; a native solution removes the need for that boilerplate and keeps output uniform across projects.
- Enables tooling downstream: leveled, parseable log lines make it realistic to build log filtering, alerting, or dashboards (e.g. tailing
log.txtand reacting only to[Error]lines) without fragile string-matching against whatever prefix a given script author chose. - Optional filtering by level: could pair naturally with a
config.jsonsetting (e.g. minimum log level) to reduce console/file verbosity in production without touching gamemode code.
This is purely additive: print()/printf() would keep working exactly as they do now.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Pawn natives in omp_core.inc and tracing how print() and printf() reach the core server's existing leveled logging. Compare the proposed separate natives with the single-level alternative, then verify that the chosen API preserves current output behavior while producing consistent severity prefixes in the console and log.txt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100