Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LogLevels #9

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions vosk/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use vosk_sys::*;
#[derive(Debug, Default, Clone, Copy)]
/// Log level for Kaldi messages.
pub enum LogLevel {
/// Print Error, Info and Debug messages.
ErrorInfoDebug,

/// Print Error and Info, but not Debug messages (default).
/// Print Error, Warn, and Info (default)
#[default]
ErrorInfo,
Info,

/// Print Error and Warn messages.
Warn,

/// Only print Error messages.
Error,
Expand All @@ -18,16 +18,16 @@ pub enum LogLevel {
impl LogLevel {
pub(self) fn to_c_int(self) -> c_int {
match self {
Self::ErrorInfo => 0,
Self::Error => -1,
Self::ErrorInfoDebug => 1,
Self::Info => 0,
Self::Warn => -1,
Self::Error => -2,
}
}
}

/// Set log level for Kaldi messages.
///
/// Default: [`LogLevel::ErrorInfo`].
/// Default: [`LogLevel::Info`].
pub fn set_log_level(log_level: LogLevel) {
unsafe { vosk_set_log_level(log_level.to_c_int()) }
}
Loading