Trait logchop::ResultLogFormatter[][src]

pub trait ResultLogFormatter<T, E> {
    fn log_format<F>(self, level: Level, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn log_ok_format<F>(self, level: Level, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn log_err_format<F>(self, level: Level, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
;
fn trace_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn trace_ok_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn trace_err_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
;
fn debug_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn debug_ok_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn debug_err_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
;
fn info_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn info_ok_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn info_err_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
;
fn warn_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn warn_ok_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn warn_err_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
;
fn error_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&Result<T, E>) -> String
;
fn error_ok_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&T) -> String
;
fn error_err_format<F>(self, f: F) -> Result<T, E>
    where
        F: FnOnce(&E) -> String
; }

Augment Result types with log methods that can print abitrary representations of wrapped values. If the type being logged implements Debug, you may be able to use ResultLogger instead.

The callsite is responsible for defining the format strategy. The closure is only evaluated when necessary.

This trait defines methods prefixed by the log level, as well as a general one that accepts a log level parameter.

  • <log_level>_format(FnOnce) prints the return value of the closure if Ok or Err
  • <log_level>_format_ok(FnOnce) prints the return value of the closure if Ok
  • <log_level>_format_err(FnOnce) prints the return value of the closure if Err

Required methods

fn log_format<F>(self, level: Level, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a log message of the provided severity if Ok or Err. The message is determined by the return value of the supplied closure.

fn log_ok_format<F>(self, level: Level, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a log message of the provided severity if Ok. The message is determined by the return value of the supplied closure.

fn log_err_format<F>(self, level: Level, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a log message of the provided severity if Err. The message is determined by the return value of the supplied closure.

fn trace_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a trace log with the return value of the provided closure.

fn trace_ok_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a trace log with the return value of the provided closure if Ok.

fn trace_err_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a trace log with the return value of the provided closure if Err.

fn debug_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a debug log with the return value of the provided closure.

fn debug_ok_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a debug log with the return value of the provided closure if Ok.

fn debug_err_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a debug log with the return value of the provided closure if Err.

fn info_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a info log with the return value of the provided closure.

fn info_ok_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a info log with the return value of the provided closure if Ok.

fn info_err_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a info log with the return value of the provided closure if Err.

fn warn_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a warn log with the return value of the provided closure.

fn warn_ok_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a warn log with the return value of the provided closure if Ok.

fn warn_err_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a warn log with the return value of the provided closure if Err.

fn error_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&Result<T, E>) -> String
[src]

Output a error log with the return value of the provided closure.

fn error_ok_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&T) -> String
[src]

Output a error log with the return value of the provided closure if Ok.

fn error_err_format<F>(self, f: F) -> Result<T, E> where
    F: FnOnce(&E) -> String
[src]

Output a error log with the return value of the provided closure if Err.

Loading content...

Implementations on Foreign Types

impl<T, E> ResultLogFormatter<T, E> for Result<T, E>[src]

Loading content...

Implementors

Loading content...