Expand description
Turnkey logging for plugins.
Provides a high-level install entry point (wrapped by the
enable_logger! and enable_logger_with! macros at the crate root)
that wires up:
- A per-plugin file under
logs/{crate}.logwith size-based rotation - A dual sink to the server’s own log (SA-MP
logprintf/ open.mpICore::logLn) - A prefix derived from the caller’s
CARGO_PKG_NAME(overridable) - A runtime-adjustable log level so the plugin can expose its own
Pawn-side knob (
SetLogLevel, etc.) - A startup banner that introspects
CARGO_PKG_*at the caller’s site
Plain log::info! / log::warn! / log::error! calls inside the
plugin route through this implementation once installed; there is no
parallel set of helper macros to remember.
Structs§
- Banner
Metadata - Manifest fields fed by the macro from the caller’s
env!values. - Logger
Config - Configuration for
install. Built via the fluent setters; defaults are derived fromCARGO_PKG_NAME(captured at the caller’s compile time byenable_logger!). - Sink
Record - Single log record handed to a
Sink. Borrows from the activelog::Recordand the SDK’s per-record context — do not retain references past theemitcall.
Enums§
- Banner
Mode - What
installdoes when the configuration’s banner is reached. - Install
Error - Errors returned by
install.
Traits§
- Sink
- Receiver of formatted log records for forwarding to an external destination chosen by the plugin author — Sentry, an OTLP collector, an in-house HTTP endpoint, a database, anything.
Functions§
- flush
- Forces the active log file to flush to disk.
- install
- Installs the SDK logger as the global
logimplementation. - level
- Current threshold — useful for diagnostic natives that want to report the active level back to scripts.
- print_
banner - Re-emits the default banner after installation. Rarely useful at
runtime; kept public so plugins can re-print on demand (for
instance, after a Pawn-driven reload). Honours
BannerMode::Defaultregardless of what was supplied toinstall— custom banners are not memoised, so plugins that need their own format should calllog::info!themselves. - set_
level - Adjusts the global threshold without reinstalling. Intended for plugin
natives that expose a runtime knob — bind it to a Pawn-callable
helper such as
MyPlugin_SetLogLevel(level).
Type Aliases§
- Banner
Builder - Type alias for the custom banner builder — receives the metadata captured by the macro and returns the lines to render.