我正在尝试编写一个函数,它将优先级和可变数量的字符串作为参数来记录应用程序中的信息。
到目前为止,该函数看起来像这样:
int _logf(int priority, char *fmt, ...)
{
if (log.priority >= priority) {
syslog(priority, "LOG:%s", fmt);
}
/* stderr and syslog */
}
log.priority是运行时的集合,int可以是LOG_INFO//LOG_DEBUGLOG_ERR
并在使用中:
_logf(LOG_INFO, "Starting app version %s", "1.0");
这是将日志消息发送到的可接受方式syslog吗?