pub struct FileSpec { /* private fields */ }Expand description
Builder object for specifying the name and path of the log output file.
assert_eq!(
FileSpec::default()
.directory("/a/b/c")
.basename("foo")
.suppress_timestamp()
.suffix("bar"),
FileSpec::try_from("/a/b/c/foo.bar").unwrap()
);Implementations§
Source§impl FileSpec
impl FileSpec
Sourcepub fn try_from<P>(p: P) -> Result<FileSpec, FlexiLoggerError>
pub fn try_from<P>(p: P) -> Result<FileSpec, FlexiLoggerError>
The provided path should describe a log file. If it exists, it must be a file, not a folder. If necessary, parent folders will be created.
§Errors
FlexiLoggerError::OutputBadFile if the given path exists and is a folder.
§Panics
Panics if the basename of the given path has no filename
Sourcepub fn basename<S>(self, basename: S) -> FileSpec
pub fn basename<S>(self, basename: S) -> FileSpec
The specified String is used as the basename of the log file name, instead of the program name. Using a file separator within the argument is discouraged.
Sourcepub fn o_basename<S>(self, o_basename: Option<S>) -> FileSpec
pub fn o_basename<S>(self, o_basename: Option<S>) -> FileSpec
The specified String is used as the basename of the log file,
instead of the program name, which is used when None is given.
Sourcepub fn directory<P>(self, directory: P) -> FileSpec
pub fn directory<P>(self, directory: P) -> FileSpec
Specifies a folder for the log files.
If the specified folder does not exist, it will be created. By default, the log files are created in the folder where the program was started.
Sourcepub fn o_directory<P>(self, directory: Option<P>) -> FileSpec
pub fn o_directory<P>(self, directory: Option<P>) -> FileSpec
Specifies a folder for the log files.
If the specified folder does not exist, it will be created. With None, the log files are created in the folder where the program was started.
Sourcepub fn discriminant<S>(self, discriminant: S) -> FileSpec
pub fn discriminant<S>(self, discriminant: S) -> FileSpec
The specified String is added to the log file name.
Sourcepub fn o_discriminant<S>(self, o_discriminant: Option<S>) -> FileSpec
pub fn o_discriminant<S>(self, o_discriminant: Option<S>) -> FileSpec
The specified String is added to the log file name.
Sourcepub fn suffix<S>(self, suffix: S) -> FileSpec
pub fn suffix<S>(self, suffix: S) -> FileSpec
Specifies a suffix for the log files.
Equivalent to o_suffix(Some(suffix)).
Sourcepub fn o_suffix<S>(self, o_suffix: Option<S>) -> FileSpec
pub fn o_suffix<S>(self, o_suffix: Option<S>) -> FileSpec
Specifies a suffix for the log files, or supresses the use of a suffix completely.
The default suffix is “log”.
Sourcepub fn suppress_timestamp(self) -> FileSpec
pub fn suppress_timestamp(self) -> FileSpec
Makes the logger not include a timestamp into the names of the log files
Equivalent to use_timestamp(false).
Sourcepub fn use_timestamp(self, use_timestamp: bool) -> FileSpec
pub fn use_timestamp(self, use_timestamp: bool) -> FileSpec
Defines if a timestamp should be included into the names of the log files.
The default behavior depends on the usage:
- without rotation, a timestamp is by default included into the name
- with rotation, the timestamp is by default suppressed
Sourcepub fn as_pathbuf(&self, o_infix: Option<&str>) -> PathBuf
pub fn as_pathbuf(&self, o_infix: Option<&str>) -> PathBuf
Creates a PathBuf to the described log file.
It is composed like this:
<directory>/<basename>_<discr>_<timestamp><infix>.<suffix>
Trait Implementations§
impl Eq for FileSpec
impl StructuralPartialEq for FileSpec
Auto Trait Implementations§
impl Freeze for FileSpec
impl RefUnwindSafe for FileSpec
impl Send for FileSpec
impl Sync for FileSpec
impl Unpin for FileSpec
impl UnsafeUnpin for FileSpec
impl UnwindSafe for FileSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<A> DynCastExt for A
impl<A> DynCastExt for A
Source§fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self,
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source>where
A: DynCastExtHelper<T>,
T: ?Sized,
Source§fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target
Source§fn dyn_cast_adv<F, T>(
self,
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
fn dyn_cast_adv<F, T>( self, ) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source>
Source§fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
fn dyn_cast_with_config<C>(
self,
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source>where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more