Skip to content

Instantly share code, notes, and snippets.

@GabrielL
Created August 17, 2011 15:14
Show Gist options
  • Save GabrielL/1151741 to your computer and use it in GitHub Desktop.
Save GabrielL/1151741 to your computer and use it in GitHub Desktop.
syslog example
#include <stdarg.h>
#include <stdlib.h>
#include <syslog.h>
void log_err(const char *format, ...)
{
va_list ap;
va_start(ap, format);
syslog(LOG_ERR, format, ap);
va_end(ap);
}
int main()
{
extern const char *__progname;
openlog(__progname, LOG_PID, LOG_USER);
syslog(LOG_WARNING, "Hi from example application");
syslog(LOG_INFO, "I can Haz Numbers, %d", 12);
log_err("Critical error");
closelog();
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment