Set syslog priority based on level in ntfs_log_handler_syslog()

pull/131/head
Andrew Sayers 2025-01-02 14:55:19 +00:00 committed by GitHub
parent 75dcdc2cf3
commit 197b31fee5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 2 deletions

View File

@ -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;