Struct rlog::Logger[][src]

pub struct Logger {
    pub path: String,
    pub format: String,
}

Main structure.

pub struct Logger {
    pub path: String,
    pub format: String,
}
  • path: filepath to the log file you want to use, can be relative.
  • format: output format to be used.

Available format tokens:

  • $time: logs time in HH:MM.SS format.
  • $timeshort: logs time in HH:MM format.
  • $date: logs current date in DD-MM-YYYY Day format, where "Day" is a three letter abbreviation of week-day name.
  • '$msg': where the actual message will be output.

Example

This example is not tested
extern crate rlog;
use rlog::Logger;

let log = Logger::new("my.log", "$date $time $msg");
assert!(log.log("Just testing"));
assert!(log.log("Another test"));

Result is in file my.log in the root directory of your crate:

10.08.2018 09:06.33 Just testing

10.08.2018 09:06.34 Another test

Fields

Methods

impl Logger
[src]

Create new instance.

Example

extern crate rlog;
use rlog::Logger;

let log = Logger::new("test.log", "$msg"); // This format will just log messages without any timestamps.

Log message msg to file.

Returns true on succesful write, false otherwise and prints error message to stderr.

Example

This example is not tested
extern crate rlog;
use rlog::Logger;

let log = Logger::new("my.log", "$date $time $msg");
assert!(log.log("Just testing"));

Auto Trait Implementations

impl Send for Logger

impl Sync for Logger