Struct rlog::Logger [−][src]
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
path: String
format: String
Methods
impl Logger
[src]
impl Logger
pub fn new(path: &str, format: &str) -> Logger
[src]
pub fn new(path: &str, format: &str) -> Logger
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.
pub fn log(&self, msg: &str) -> bool
[src]
pub fn log(&self, msg: &str) -> bool
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"));