Struct flexi_config::FlexiConfig
[−]
[src]
pub struct FlexiConfig { pub project: String, pub dependencies: BTreeMap<String, Option<Priority>>, pub target: Target, pub stderr_format: LogFormat, pub disk_format: LogFormat, pub disk_dir: Option<String>, pub disk_dup_err: bool, pub disk_dup_info: bool, pub disk_filename_ext: String, pub disk_filename_time: bool, pub disk_file_size: Option<u32>, pub disk_filename_suffix: Option<String>, pub app_priority: Priority, pub issues: Option<Issues>, }
Fields
project: String
Defines the list of modules the application depends on.
dependencies: BTreeMap<String, Option<Priority>>
Defines the list of modules the application depends on and what priority their log messages are at.
target: Target
Defines where the log messages should be written to, files or stderr? By default this is set to stderr.
stderr_format: LogFormat
Defines the log format when writing to stderr. By default this will use the flexi_logger default format.
disk_format: LogFormat
Defines the log format when writing to a file. By default this will use the flexi_logger detailed format.
disk_dir: Option<String>
If logging to a file is enabled, this sets the directory to write to. By default (None) it will write to the current directory.
disk_dup_err: bool
When logging to a file, flexi_logger can duplicate any error messages to stdout. The default is to duplicate the error messages.
disk_dup_info: bool
When logging to a file, flexi_logger can duplicate any info messages to stdout. The default is to not duplicate the messages.
disk_filename_ext: String
The extension for the log file. By default this is "log".
disk_filename_time: bool
Flag to tell flexi_logger to include the timestamp when a log file is created. This is set to true by default. If the file_limit_size is set however this value will be ignored.
disk_file_size: Option<u32>
If set, limits the size of the log file in megabytes. When this size is reached a new file is created. If this value is set the log files will have a sequence number rather than a time stamp.
disk_filename_suffix: Option<String>
Adds a suffix to the log file names after the program name.
app_priority: Priority
Sets the lowest priority to report for you application. The default priority is Warn.
issues: Option<Issues>
If the object was loaded from a TOML configuration file, this object will contain any issues encountered while loading the file.
Methods
impl FlexiConfig
[src]
fn from_cargo_file<P: AsRef<Path>>(file: P) -> Result<FlexiConfig, Issues>
Construct a new object from a Cargo.toml file located on disk.
This object is used to customize the configuration file that is created. The following default settings are used:
The default target is to log to stderr. The stderr message format is set to "default" and the default message format when writing to a file is "detailed".
No log directory is defined so logs will be generated in the current directory. The default extension is "log" with a timestamp added to the name of the log file.
When logging to a file error messages will be echoed to stdout.
The default log level for your program is set to warning, while the log level for dependencies will be set to error.
fn from_cargo(file: &str) -> Result<FlexiConfig, Issues>
Construct a new object from a Cargo.toml file located in memory.
This object is used to customize the configuration file that is created. The following default settings are used:
The default target is to log to stderr. The stderr message format is set to "default" and the default message format when writing to a file is "detailed".
No log directory is defined so logs will be generated in the current directory. The default extension is "log" with a timestamp added to the name of the log file.
When logging to a file error messages will be echoed to stdout.
The default log level for your program is set to warning, while the log level for dependencies will be set to error.
impl FlexiConfig
[src]
fn from_toml(toml: Table) -> Result<FlexiConfig, Issues>
Construct an instance of FlexiConfig by parsing a TOML data structure.
fn from_toml_string(input: &str) -> Result<FlexiConfig, Issues>
Construct an instance of FlexiConfig by parsing a TOML file in a string.
fn from_toml_file<P: AsRef<Path>>(file: P) -> Result<FlexiConfig, Issues>
Construct an instance of FlexiConfig by reading a TOML configuration file from disk.
impl FlexiConfig
[src]
fn to_toml_string(self) -> String
Destroys the object and creates the config TOML file in a string.
fn to_toml_file<P: AsRef<Path>>(self, file: P) -> Result<(), String>
Destroys the object and saves the TOML config file on disk.
impl FlexiConfig
[src]
fn project(self, project: &str) -> FlexiConfig
Convenience method to set the project.
fn dependencies(self, name: &str, priority: Option<Priority>) -> FlexiConfig
Convenience method to set the list of dependencies.
fn all_dependencies(self, priority: Option<Priority>)
Set the priority for all dependencies to the same value.
fn target(self, target: Target) -> FlexiConfig
Convenience method to set the target.
fn stderr_format(self, format: LogFormat) -> FlexiConfig
Convenience method to set the stderr log format.
fn disk_format(self, format: LogFormat) -> FlexiConfig
Convenience method to set the file log format.
fn disk_dir(self, dir: &str) -> FlexiConfig
Convenience method to set the log directory.
fn disk_dup_err(self, duplicate: bool) -> FlexiConfig
Convenience method to set the duplicate error flag.
fn disk_dup_info(self, duplicate: bool) -> FlexiConfig
Convenience method to set the duplicate info flag.
fn disk_filename_ext(self, ext: &str) -> FlexiConfig
Convenience method to set the extension for the log files.
fn disk_filename_time(self, enable: bool) -> FlexiConfig
Convenience method to enable/disable a timestamp in the log file names.
fn disk_file_size(self, size: u32) -> FlexiConfig
Convenience method to set the file size limit.
fn disk_filename_suffix(self, suffix: &str) -> FlexiConfig
Convenience method to set the log file name suffix.
fn app_priority(self, level: Priority) -> FlexiConfig
Convenience method to set the level for logging messages from the application.
impl FlexiConfig
[src]
fn new(project: &str, dependencies: BTreeMap<String, Option<Priority>>) -> FlexiConfig
Common structor that creates a FlexiConfig object with the default values.
fn apply(self) -> Result<(), String>
Apply the configuration to flexi_logger;
Trait Implementations
impl Clone for FlexiConfig
[src]
fn clone(&self) -> FlexiConfig
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more