pub fn load_config_from_file(path: &str) -> Result<(), ReadFromConfigFileError>Expand description
§Loads config from the given file
§Supported file extensions:
- ini
- json
- env
§Allowed fields in each file:
enabled: bool
level: str
print_to_terminal: bool
colorized: bool
global_formatting: str
trace_formatting: str
debug_formatting: str
info_formatting: str
warn_formatting: str
error_formatting: str
file_name: str
compression: str
rotations: arr[str]
archive_dir: strNote: For the
iniandenvfiles, for rotations you should write a single string with ‘,’ divisor, example:
rotations = "1 week, 12 MB, 12:30"Note: For the ini files, the config must be in the
[Config]sections
Example for an ini file:
[Config]
colorized=true
global_formatting="{file}-{line}-{module}<red> it seem to work<red> {level}: {message}"
warn_formatting = "{file}-{line}-{module}<red>WARN!<red> {message}"
file=app_{date}_{time}.txt rotations="1 day, 12:30"
archive_dir="archives_loggit"Example for a json file:
{
"colorized": "true",
"global_formatting": "<blue>{message}<blue> --- {level}",
"file_name": "app_{time}.txt",
"rotations": [
"1 day",
"12:30",
"10 MB"
]
}Note: in a json file you must pass an array of string for rotations (not as in other files where you pass it with ‘,’ (coma))
Example for a env file:
colorized=true
global_formatting="{file}-{line}-{module}<red>blyaaaa<red> {level}: {message}"
file="ok_test_app_{date}_{time}.txt"
rotations="1 day"
archive_dir="archives_loggit"