pub struct LoggerConfig { /* private fields */ }Expand description
Configuration for install. Built via the fluent setters; defaults
are derived from CARGO_PKG_NAME (captured at the caller’s compile time
by enable_logger!).
Implementations§
Source§impl LoggerConfig
impl LoggerConfig
Sourcepub fn new(crate_name: impl Into<String>) -> Self
pub fn new(crate_name: impl Into<String>) -> Self
Builds a config seeded from the caller’s CARGO_PKG_NAME — the
enable_logger! macro is the intended entry point and forwards
env!("CARGO_PKG_NAME") here automatically.
Sourcepub fn directory(self, path: impl Into<PathBuf>) -> Self
pub fn directory(self, path: impl Into<PathBuf>) -> Self
Directory under which the active log file lives. Default: logs/.
The path is resolved relative to the server’s working directory.
Rotated archives are always placed under {directory}/archive/ —
the active log stays directly in directory so the folder root
shows only current files.
Sourcepub fn filename(self, name: impl Into<String>) -> Self
pub fn filename(self, name: impl Into<String>) -> Self
Filename inside directory. Default: {crate-name}.log.
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Prefix prepended to every line written to the server’s log.
Default: [{crate-name}]. The plugin’s dedicated file omits the
prefix because every line in it already belongs to this plugin.
Sourcepub fn level(self, level: LevelFilter) -> Self
pub fn level(self, level: LevelFilter) -> Self
Threshold below which log::warn!, log::info! and friends are
silently dropped. Default: LevelFilter::Info. Can be adjusted
at runtime via set_level.
Sourcepub fn also_to_server(self, enabled: bool) -> Self
pub fn also_to_server(self, enabled: bool) -> Self
Whether each log line is also forwarded to the server’s own log
(visible in the server console and the server’s main log file).
Default: true.
Selects the banner strategy. Default: BannerMode::Default (the
built-in 5-line banner). Pass BannerMode::Off to suppress
every banner line, or BannerMode::Custom to render the lines
yourself.
Shorthand for banner(BannerMode::Off).
Shorthand for banner(BannerMode::Custom(Box::new(builder))).
builder receives the manifest fields captured by the macro and
returns the lines to render — each line goes out at Info level
through the same pipeline as the rest of the logger.
Sourcepub fn file_format(self, format: impl Into<String>) -> Self
pub fn file_format(self, format: impl Into<String>) -> Self
Layout for lines written to the plugin’s dedicated log file.
Placeholders honoured: {timestamp}, {level}, {message}.
Default: "[{timestamp}] [{level}] {message}".
Sourcepub fn server_format(self, format: impl Into<String>) -> Self
pub fn server_format(self, format: impl Into<String>) -> Self
Layout for lines forwarded to the server console.
Placeholders honoured: {prefix}, {level}, {message}.
Default: "{prefix} {message}".
Sourcepub fn no_rotation(self) -> Self
pub fn no_rotation(self) -> Self
Disable size-based rotation entirely. The active log file grows
indefinitely — only set this if an external rotator (e.g.
logrotate) takes over.
Sourcepub fn rotation_size_mb(self, mb: u64) -> Self
pub fn rotation_size_mb(self, mb: u64) -> Self
Threshold at which the active file is rotated, in megabytes. Default: 50 MB. Disables rotation if set to 0.
Whether old archives are deleted is controlled separately by
rotation_keep — by default the SDK never deletes; it only
renames into the archive directory.
Sourcepub fn rotation_keep(self, keep: u32) -> Self
pub fn rotation_keep(self, keep: u32) -> Self
Opts in to size-bounded cleanup: keep the latest keep archives
(newest = .log.1, oldest = .log.{keep}) and delete anything
older. Total disk footprint becomes (keep + 1) * rotation_size_mb.
Off by default — the SDK never deletes log files unless the dev explicitly requests it.
Sourcepub fn rotation_no_cleanup(self) -> Self
pub fn rotation_no_cleanup(self) -> Self
Reverts to append-style rotation — every rotated file gets a
fresh, never-reused index and the SDK never deletes anything.
This is the default; the method exists so a builder chain can
undo a previous .rotation_keep(N).