pub struct ConfigBuilder { /* private fields */ }
Expand description

Builder for Config.

The ConfigBuilder can set the different parameters of Config object, and returns the created object when build is called.

§Example

use gelf_logger::ConfigBuilder;

let cfg = ConfigBuilder::default()
    .set_hostname("localhost".into())
    .build();

Implementations§

source§

impl ConfigBuilder

source

pub fn try_from_yaml(path: &str) -> Result<ConfigBuilder, Error>

Load configuration using the given path file.

§Example
use gelf_logger::ConfigBuilder;

let config = ConfigBuilder::try_from_yaml("/tmp/myconf.yml")
    .expect("Invalid config file!")
    .build();
source

pub fn set_level(self, level: GelfLevel) -> ConfigBuilder

Sets threshold for this logger to level. Logging messages which are less severe than level will be ignored.

source

pub fn set_hostname(self, hostname: String) -> ConfigBuilder

Sets the hostname of the remote server.

source

pub fn set_port(self, port: u64) -> ConfigBuilder

Sets the port of the remote server.

source

pub fn set_null_character(self, null_character: bool) -> ConfigBuilder

Adds a NUL byte (\0) after each entry.

source

pub fn set_use_tls(self, use_tls: bool) -> ConfigBuilder

Activate transport security.

source

pub fn set_async_buffer_size(self, async_buffer_size: usize) -> ConfigBuilder

Set the asynchronous buffer size. This buffer is placed between the log subsystem and the network sender. This represent the maximum number of message the system will buffer before blocking while waiting for message to be actually sent to the remote server.

Default: 1000

§Warning

This actually allocates a buffer of this size, if you set a high value here, is will eat a large amount of memory.

source

pub fn set_buffer_size(self, buffer_size: usize) -> ConfigBuilder

Sets the upperbound limit on the number of records that can be placed in the buffer, once this size has been reached, the buffer will be sent to the remote server.

source

pub fn set_buffer_duration(self, buffer_duration: Duration) -> ConfigBuilder

Sets the maximum lifetime of the buffer before send it to the remote server.

source

pub fn put_additional_field<V>(self, key: String, value: V) -> ConfigBuilder
where V: Into<Value>,

Adds an additional data which will be append to each log entry.

source

pub fn extend_additional_fields( self, additional_fields: BTreeMap<Value, Value> ) -> ConfigBuilder

Adds multiple additional data which will be append to each log entry.

source

pub fn set_full_buffer_policy( self, policy: Option<FullBufferPolicy> ) -> ConfigBuilder

Set the policy to apply when async send buffer is full.

It is recommended to use the FullBufferPolicy::Discard policy.

If not set or set to None, FullBufferPolicy::Discard will be used by default

source

pub fn set_connect_timeout( self, connect_timeout: Option<Duration> ) -> ConfigBuilder

Set the TCP connect timeout.

source

pub fn set_write_timeout(self, write_timeout: Option<Duration>) -> ConfigBuilder

Set the TCP write timeout.

source

pub fn build(self) -> Config

Invoke the builder and return a Config

Trait Implementations§

source§

impl Clone for ConfigBuilder

source§

fn clone(&self) -> ConfigBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ConfigBuilder

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ConfigBuilder

source§

fn default() -> Self

Construct default ConfigBuilder.

Defaults values are:

  • level: GelfLevel::Alert
  • hostname: “127.0.0.1”
  • port: 12202
  • null_character: true
  • use_tls: true
  • buffer_size: None
  • buffer_duration: None
  • additional_fields: empty BTreeMap
source§

impl<'de> Deserialize<'de> for ConfigBuilder

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,