[−][src]Struct paris::Logger
Implementations
impl Logger
[src]
pub fn new() -> Self
[src]
pub fn log<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Prints to stdout with no bells and whistles. I does however add a timestamp if enabled.
Example
let mut logger = Logger::new(); logger.log("Basic and boring."); // Basic and boring.
Equivalent macro: log!()
pub fn info<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Prints to stdout and adds some info flair to the text
Example
logger.info("This is some info");
Equivalent macro: info!()
pub fn success<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Prints to stdout and adds some success flair to text
Example
logger.success("Everything went great!");
Equivalent macro: success!()
pub fn warn<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Prints to stdout and adds some warning flare to text
Example
logger.warn("This is a warning");
Equivalent macro: warn!()
pub fn error<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Prints to stderr and adds some error flare to text
Example
logger.error("Something broke, here's the error");
Equivalent macro: error!()
pub fn newline(&mut self, amount: usize) -> &mut Logger
[src]
Prints a specified amount of newlines to stdout
Example
logger .newline(5) .info("Some newlines before info") .newline(2) .info("And some more in between");
pub fn indent(&mut self, amount: usize) -> &mut Logger
[src]
Prints a specified amount of tabs to stdout
Example
logger .indent(1) .warn("Indented warning eh? Stands out a bit") .newline(5);
pub fn loading<T: Display>(&mut self, message: T) -> &mut Logger
[src]
Starts a loading animation with the given message.
Example
let mut logger = Logger::new(); logger.loading("Counting to 52!"); // counting happens here (somehow) logger .done() .success("Done counting, only took 1 million years");
That's one way of doing it, but having to always call .done()
doesn't
look that tidy. Well you don't have to, unless you want. All other functions
(success, info, error, etc.) call .done()
just in case a loading thread is running
already. A cleaner example would be:
let mut logger = Logger::new(); logger.loading("Counting to 52! again"); // .... logger.error("I give up, I can't do it again!");
pub fn done(&mut self) -> &mut Logger
[src]
Stops the loading animation and clears the line so you can print something else when loading is done, maybe a success message. All other methods (success, warning, error, etc.) call this one automatically when called so you can use one of those directly for less clutter.
pub fn same(&mut self) -> &mut Logger
[src]
Forces the next statement to not output a newline
Example
logger .same().log("This is on one line") .indent(4) .log("This is on the same line!");
pub fn add_style(&mut self, key: &str, colors: Vec<&str>) -> &mut Logger
[src]
Add a custom key to the available list of keys
Example
logger.add_style("lol", vec!["green", "bold", "on_blue"]); // '<lol>' can now be used as a key in strings and will contain // the defined colors and styles logger.info("<lol>much shorter than writing all of them</>");
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl !UnwindSafe for Logger
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,