From 0eb7abc7e281c1a321e4f7c6e5b7fd6270fc3391 Mon Sep 17 00:00:00 2001 From: MadelynWith5Ns Date: Sun, 19 May 2024 22:58:48 -0500 Subject: [PATCH] docs: update the readme slightly --- README | 7 ------ README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 7 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 3d76c27..0000000 --- a/README +++ /dev/null @@ -1,7 +0,0 @@ -Vanessa is a semi-opinionated, dependency-free, threading and utility library -for Rust programs. - --- Cargo features -- -multilog: Enabling this causes Vanessa's logger to store its current log file -in the logs/latest.log file instead of simply latest.log and store old logs -alongside them in the logs directory. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0ef2b3 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Vanessa + +Vanessa is a utility library for Rust programs. + +It provides an extremely easy logger and dead-simple threading. + +### Logging + +Logging is super simple, initialize it at the start of your program +and you can use the various log level macros anywhere in your program! +You can also create new loggers and log to them with the `s` macros +(like `sinfo!` or `sdebug!`). Loggers have 7 levels here: + +- Hyper: Hyper is for really spammy debug messaging. The default logger +and any logger from `Logger::quick` has the log level set too high +for these. + +- Debug: Debug is for debug messaging (obviously). The default logger +and any logger from `Logger::quick` will only show these when compiling +in debug mode. + +- Info: Normal info messages. + +- Warn: Warnings. + +- Error: Errors. + +- Fatal: Critical errors, this is for full-program crashes or other +similarly critical failures. + +- Input: This is a special log level used to get input from the user. +Its macro returns an `Option`. + +```rust +use vanessa::{info,sinfo}; + +fn main() { + // call this somewhere at the start of your program + vanessa::log::init(); + // or just call vanessa::full_init() to init everything! + + info!("Hello World!"); + + let logger2 = vanessa::log::Logger::quick("Another Logger"); + sinfo!(logger2, "You can also log to specific loggers which can have their own log levels!"); +} +``` + +### Threading + +Concurrency is done via background workers. Call the init function +at the start of your program and you can call the `bg` function from +anywhere to run a closure in the background! + +```rust +use vanessa::worker::bg; + +fn main() { + // call this somewhere at the start of your program + vanessa::worker::init(); + // or just call vanessa::full_init() to init everything! + // you can also call vanessa::worker::init_with(usize) + // to initialize with a specified number of threads. + + bg(||{ + // background tasks! + }); +} +```