Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced Logging priority based loggin functions
Browse files Browse the repository at this point in the history
which call the generic logging function
DJawna committed Oct 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent eb781c2 commit 383eb6e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/sdl2/log.rs
Original file line number Diff line number Diff line change
@@ -122,6 +122,42 @@ pub fn log(message: &str) {
}
}

/// Log function which takes as priority CRITICAL and category APPLICATION
#[doc(alias = "SDL_LogCritial")]
pub fn log_critical(message: &str) {
log_with_category(message, Category::Application, Priority::Critical);
}

/// Log function which takes as priority DEBUG and category APPLICATION
#[doc(alias = "SDL_LogDebug")]
pub fn log_debug(message: &str) {
log_with_category(message, Category::Application, Priority::Debug);
}

/// Log function which takes as priority ERROR and category APPLICATION
#[doc(alias = "SDL_LogError")]
pub fn log_error(message: &str) {
log_with_category(message, Category::Application, Priority::Error);
}

/// Log function which takes as priority INFO and category APPLICATION
#[doc(alias = "SDL_LogInfo")]
pub fn log_info(message: &str) {
log_with_category(message, Category::Application, Priority::Info);
}

/// Log function which takes as priority VERBOSE and category APPLICATION
#[doc(alias = "SDL_LogVerbose")]
pub fn log_verbose(message: &str) {
log_with_category(message, Category::Application, Priority::Verbose);
}

/// Log function which takes as priority WARN and category APPLICATION
#[doc(alias = "SDL_LogWarn")]
pub fn log_warn(message: &str) {
log_with_category(message, Category::Application, Priority::Warn);
}

/// Log function where Category and Priority can be specified
pub fn log_with_category(message: &str, category: Category, priority: Priority) {
let message = message.replace('%', "%%");

0 comments on commit 383eb6e

Please sign in to comment.