Skip to content

Feature request: log level support for Pawn scripts (print/printf) #1254

Description

@RonaldoBueno16

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.txt for [Error]/[Warning] immediately isolates real problems from routine info output, instead of scrolling through everything printf() 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.txt and 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.json setting (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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions