log4wasm 0.1.3

A stylish rust-generated WebAssembly logging utility.
Documentation
pub mod logger;
pub mod styled;

/// Provides a suite of preset loggers capable of writing an output to the browser console. The log macros serve as
/// a shorthand approach for convenience in instances where building a custom logger is not needed. The log macros 
/// support both formatted and unformatted outputs where the formatted option allows for passing in additional arguments
/// defining how the output should be formatted along with the relative values to be included.
///
/// Currently, the following levels are supported for use through the appropriate log macro:
/// - `FATAL`
/// - `ERROR`
/// - `WARN`
/// - `INFO`
/// - `DEBUG`
/// - `TRACE`
///
/// ## Example
///
/// ```rust,no_run
/// use log4wasm::log;
///
/// log::info!("This will write an unformatted output with a level of INFO.");
/// log::error!("This will write a formatted output with a level of ERROR: {}", "some error context");
/// ```
#[macro_use]
pub mod log {
    #[macro_export]
    macro_rules! trace {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Trace, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Trace, $text))
        };
    }

    #[macro_export]
    macro_rules! debug {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Debug, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Debug, $text))
        };
    }

    #[macro_export]
    macro_rules! info {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Info, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Info, $text))
        };
    }

    #[macro_export]
    macro_rules! warning {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Warn, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Warn, $text))
        };
    }

    #[macro_export]
    macro_rules! error {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Error, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Error, $text))
        };
    }

    #[macro_export]
    macro_rules! fatal {
        ($text:tt, $($args:tt)*) => {
            $crate::logger::log(&std::format!("{}\t{}{}", log4wasm::logger::Level::Fatal, $text, $($args)*))
        };

        ($text:tt) => {
            log4wasm::logger::log(&std::format!("{}\t{}", log4wasm::logger::Level::Fatal, $text))
        };
    }

    pub use {trace, debug, info, warning, error,fatal};
}