Expand description
§LuhLog
A way to log your messages, it is nothing special at all. It has a formatting system, convient macros and a global logger system >.<
It is made with love though s.c <3
So as a library we expose luhlog::Logger and trait luhlog::Log
for making custom log and also exposing luhlog::LogFormatter for
formatting.
luhlog::Level has 6 levels similar to the log crate with Trace
being the lowest and Critical being the heighest in terms of precedence
we have corresponding macros for those levels for now they only
correspond to the global logger instance through get_logger().
This is still in dev stages I will amend that soon. Thank you for your patience.
We also provide luhlog::GlobalLogger for making your own global
logger instance. Look at examples below for usage…
§Examples
use luhlog::{set_logger, Level, CompactFormatter, info, warn, trace};
fn main() {
// level sets the requirement... logs below this wont be logged
// formatter sets the formatter needs to implement LogFormatter
set_logger!(level: Level::Info, formatter: CompactFormatter);
info!("hello world");
warn!(target: "main", "targeting main <3");
// wont be printed
trace!("bine");
}use luhlog::{set_logger, get_logger, Level, LogBuilder, Log, Logger, CompactFormatter};
fn main() {
set_logger!(level: Level::Trace);
let logger = get_logger();
let other_logger = Logger::with_formatter(
Level::Info,
std::sync::Arc::new(CompactFormatter)
).no_stdout().file("test.log").expect("failed to open test.log");
// this allows for finer control of what your printing
logger.log(
// this has a default level of Info
LogBuilder::new("hello guys <3")
.level(Level::Trace)
.build()
);
other_logger.log(
LogBuilder::new("in the file >.<")
.target("main")
.level(Level::Warn)
.location(file!(), line!())
.build()
);
}use luhlog::{GlobalLogger, Log, Level, LogBuilder};
static LOG: GlobalLogger = GlobalLogger::new();
fn main() {
LOG.get().log(
LogBuilder::new("test for GlobalLogger :3")
.target("LOG")
.level(Level::Info)
.location(file!(), line!())
.build()
);
}Hope you guys enjoy… any features or issues please message me
- Thank you for reading :)
Modules§
Macros§
- debug
- Logs a message at [
Level::Debug]. - error
- Logs a message at [
Level::Error]. - info
- Logs a message at [
Level::Info]. - log
- The base macro for all logging in
luhlog. - set_
logger - A convenient macro for setting up the global logger.
- trace
- Logs a message at [
Level::Trace]. - warn
- Logs a message at [
Level::Warn].
Structs§
- Compact
Formatter - Small basic formatter
- Default
Formatter - In the name a default formatter <3
- Global
Logger luhlog::GlobalLoggerprovides a simple thread-safe global logging container. It allows you to store and retrieve a single shared logger instance across your entire program.- Json
Formatter luhlog::JsonFormatterbarely works at all if you need this write your own implementation using serde escaping json this will not work in prod!!!- LogBuilder
luhlog::LogBuilderis an easy way to build aLogRecord. Doesn’t really do much apart from shorter combinators and a predefined level for the record.- LogRecord
luhlog::LogRecordcarries all appropriate metadata for a given log entry. There are two ways this is useful to you.- Logger
luhlog::Loggeris the main logging backend implementation. It handles log filtering, formatting, writing to files, and optional output to stdout.
Enums§
- Level
luhlog::Levelis an enum representing the verbosity of a given message
Traits§
- Log
luhlog::Logis the core trait that powers all logging backends.- LogFormatter
luhlog::LogFormatterdecides how your logs look.
Functions§
- clear_
logger - Clears the currently active global logger.
- flush
- Flushes the global logger’s internal records.
- get_
logger - Retrieves the active global logger instance.
- set_
logger - Sets the global logger for this library instance.