Skip to main content

LoggerConfig

Struct LoggerConfig 

Source
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

Source

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.

Source

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.

Source

pub fn filename(self, name: impl Into<String>) -> Self

Filename inside directory. Default: {crate-name}.log.

Source

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.

Source

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.

Source

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.

Source

pub fn banner(self, mode: BannerMode) -> Self

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.

Source

pub fn no_banner(self) -> Self

Shorthand for banner(BannerMode::Off).

Source

pub fn banner_with<F>(self, builder: F) -> Self
where F: Fn(&BannerMetadata) -> Vec<String> + Send + Sync + 'static,

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.

Source

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}".

Source

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}".

Source

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.

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Debug for LoggerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.