From 197b31fee52a32ca24a8437ea4b4ea4ce70ef232 Mon Sep 17 00:00:00 2001 From: Andrew Sayers Date: Thu, 2 Jan 2025 14:55:19 +0000 Subject: [PATCH] Set syslog priority based on level in ntfs_log_handler_syslog() --- libntfs-3g/logging.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/logging.c b/libntfs-3g/logging.c index ccccbb8f..2d3dbba9 100644 --- a/libntfs-3g/logging.c +++ b/libntfs-3g/logging.c @@ -369,9 +369,24 @@ int ntfs_log_handler_syslog(const char *function __attribute__((unused)), if ((level & NTFS_LOG_LEVEL_PERROR) && errno == ENOSPC) return 1; #endif + int priority; + if ( level <= NTFS_LOG_LEVEL_DEBUG ) { + priority = LOG_DEBUG; + } else if ( level <= NTFS_LOG_LEVEL_INFO ) { + priority = LOG_INFO; + } else if ( level <= NTFS_LOG_LEVEL_WARNING ) { + priority = LOG_NOTICE; + } else if ( level <= NTFS_LOG_LEVEL_ERROR ) { + priority = LOG_ERR; + } else if ( level <= NTFS_LOG_LEVEL_CRITICAL ) { + priority = LOG_CRIT; + } else { + priority = LOG_ALERT; + } + ret = vsnprintf(logbuf, LOG_LINE_LEN, format, args); if (ret < 0) { - vsyslog(LOG_NOTICE, format, args); + vsyslog(priority, format, args); ret = 1; goto out; } @@ -382,7 +397,7 @@ int ntfs_log_handler_syslog(const char *function __attribute__((unused)), ret = strlen(logbuf); } - syslog(LOG_NOTICE, "%s", logbuf); + syslog(priority, "%s", logbuf); out: errno = olderr; return ret;