pub fn log(&mut self, level: Level, message: &str) {
        if level > self.loglevel {
            return;
        }

        let timestamp = Local::now().format("%Y-%m-%d %H:%M:%S");

        if let Some(ref mut logfile) = self.logfile {
            let line = format!("[{}] {}: {}\n", timestamp, level, message);

            // Ignoring the error since checking every log() call will be too bothersome.
            let _ = logfile.write_all(line.as_bytes());
        }

        if level == Level::UserError {
            if let Some(ref mut errorlogfile) = self.errorlogfile {
                let line = format!("[{}] {}\n", timestamp, message);

                // Ignoring the error since checking every log() call will be too bothersome.
                let _ = errorlogfile.write_all(line.as_bytes());
            }
        }
    }
/// Writes a message to a log.
///
/// If `level` is lower than the logger's current level, the message won't be written. For
/// example, if Logger's level is set to Level::Critical, then Level::Error won't be written.
///
/// Level::UserError messages are written to two logs: the general one, and error-logfile. See
/// Logger description for details.
///
/// # Errors
///
/// If the message couldn't be written for whatever reason, this function ignores the failure.
/// Were you to check the return value of every log() call, you'd just stop writing logs.
Writes a message to a log.
If `level` is lower than the logger's current level, the message won't be written. For
example, if Logger's level is set to Level::Critical, then Level::Error won't be written.

:UserError messages are written to two logs: the general one, and error-logfile. See
Logger description for details.
Writes a message to a log . If ` level ` is lower than the logger ' s current level the message won ' t be written . For example if Logger ' s level is set to Level :: Critical then Level :: Error won ' t be written . : UserError messages are written to two logs : the general one and error - logfile . See Logger description for details .
pub fn log(&mut self, level: Level, message: &str) {
        if level > self.loglevel {
            return;
        }
        let timestamp = Local::now().format("%Y-%m-%d %H:%M:%S");
        if let Some(ref mut logfile) = self.logfile {
            let line = format!("[{}] {}: {}\n", timestamp, level, message);
            // Ignoring the error since checking every log() call will be too bothersome.
            let _ = logfile.write_all(line.as_bytes());
        }
        if level == Level::UserError {
            if let Some(ref mut errorlogfile) = self.errorlogfile {
                let line = format!("[{}] {}\n", timestamp, message);
                // Ignoring the error since checking every log() call will be too bothersome.
                let _ = errorlogfile.write_all(line.as_bytes());
            }
        }
    }
pub fn log ( & mut self , level : Level , message : & str ) { if level > self . loglevel { return ; } let timestamp = Local :: now ( ) . format ( " " ) ; if let Some ( ref mut logfile ) = self . logfile { let line = format ! ( " \n " timestamp level message ) ; // Ignoring the error since checking every log() call will be too bothersome. let _ = logfile . write_all ( line . as_bytes ( ) ) ; } if level == Level :: UserError { if let Some ( ref mut errorlogfile ) = self . errorlogfile { let line = format ! ( " \n " timestamp message ) ; // Ignoring the error since checking every log() call will be too bothersome. let _ = errorlogfile . write_all ( line . as_bytes ( ) ) ; } } }
Writes a message to a log.
Writes a message to a log .
&mut self
level
Level
message
&str
&mut self
level
Level
message
&str
errors
If the message couldn't be written for whatever reason, this function ignores the failure.
Were you to check the return value of every log() call, you'd just stop writing logs.
If the message couldn ' t be written for whatever reason this function ignores the failure . Were you to check the return value of every log () call you ' d just stop writing logs .