rs-common 0.1.0

The basics of the rs-toolbox project. Contains common code between repositories.
Documentation
use logs::LevelFilter;

use crate::errors::Error;

/// The logs#initialise function initialises the `env_logger` and `logs` modules.
/// This currently only consists of setting the level filter but may be extended
/// in the future.
///
/// ## Parameters
///
/// * min_level: LevelFilter -  The minimum log-level required to be printed to the console, all log requests
///                             below this level will be ignored.
///
pub fn initialise(min_level: LevelFilter) -> Result<(), Error> {
    let result = env_logger::builder().filter_level(min_level).try_init();
    if result.is_err() {
        return Error::InitialisationError(
            "01",
            "Could not initialise logging: Unknown error with the env_logger crate."
        ).into();
    }

    Ok(())
}