pub struct LogFileWriterBuilder {
    pub max_keep_age: Option<Duration>,
    pub max_keep_bytes: u64,
    pub max_write_age: Duration,
    pub max_write_bytes: u64,
    pub path_prefix: PathBuf,
}

Fields§

§max_keep_age: Option<Duration>§max_keep_bytes: u64§max_write_age: Duration§max_write_bytes: u64§path_prefix: PathBuf

Implementations§

source§

impl LogFileWriterBuilder

source

pub fn with_max_keep_age(self, duration: Duration) -> Self

Configures the struct to continuously delete files that match path_prefix and are older than max_keep_age.

Defaults to 24 hours.

Panics

Panics when duration is less than 1 minute.

source

pub fn with_max_write_age(self, duration: Duration) -> Self

Configures the struct to close the current file and create a new file whenever the current file is older than duration.

Defaults to 10 MiB.

Panics

Panics when duration is less than 1 second.

source

pub fn with_max_write_bytes(self, len: u64) -> Self

Configures the struct to write len bytes or less to each log file before switching to a new one.

Panics

Panics when len is less than 64 KiB.

source

pub fn start_writer_thread(self) -> Result<SyncSender<LogEvent>, Error>

Creates the first log file and starts the log file writer thread.

Errors

Returns Err when it fails to create the first log file.

Examples found in repository?
examples/http-put.rs (line 82)
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
pub fn main() {
    println!("Access the server at http://127.0.0.1:8000/upload");
    let _guard = set_global_logger(
        LogFileWriter::new_builder("log", 100 * 1024 * 1024)
            .start_writer_thread()
            .unwrap(),
    )
    .unwrap();
    safina_timer::start_timer_thread();
    let executor = safina_executor::Executor::default();
    let cache_dir = TempDir::new().unwrap();
    let state = Arc::new(State::new());
    let request_handler =
        move |req: Request| log_request_and_response(req, |req| handle_req(state, req)).unwrap();
    executor
        .block_on(
            HttpServerBuilder::new()
                .listen_addr(socket_addr_127_0_0_1(8000))
                .max_conns(100)
                .small_body_len(64 * 1024)
                .receive_large_bodies(cache_dir.path())
                .spawn_and_join(request_handler),
        )
        .unwrap();
}

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more