TODO:
- "parse" function to build custom combinations and styles
A logger for CLI applications | crates.io |
Basic example
use Logger;
let logger = new;
logger.info;
// ℹ This is a very basic example
API
The crate is built so that everything can be chained as many times as you need. Maybe you want to start a very intensive task, show a loading animation and as soon as that task is finished show a success message and then another loading animation:
use Logger;
let logger = new;
logger.loading;
// Do the things
logger
.success
.loading;
// Do more things
logger.error;
If you want a timestamp with all your logs you can pass true
to the
constructor
let logger = new; // true means "add timestamp"
Here's a list of all the functions (they're not that many)
logger.info; // ℹ message
logger.error; // ✖ message
logger.warn; // ⚠ message
logger.success; // ✔ message
logger.log; // message
logger.done; // Just stops the loading animation
logger
.indent
.info;
// \t\t\t ℹ Indent just adds specified amount of tabs
logger.newline.info;
// \n\n ℹ Newline is like .indent but with newlines
logger.same.log;
To start a loading animation you can run .loading()
and to end that
animation you can run any other function (except for .same()
) and the
text that was visible when loading will be replaced with your new log
logger.loading;
// will replace "Loading animation!!" with a success message
logger.success;