Files
RedBear-OS/tests/syslog/syslog.c
T
Josh Megnauth 64d9847e37 Linux support for syslog.h
Linux's syslog is a local socket, so this uses the recent UDS work.

* Most of redox.rs is refactored into mod.rs now which has all of the C
  facing functions and consts.
* I wrapped the global logger in a Mutex instead of a RwLock. The logger
  is almost always locked for writing so a Mutex is simpler as RwLock
  provides no benefits.
* I implemented LOG_PERROR which also prints errors to stderr as well as
  the log.
* Syslog should be sys/syslog.h with syslog.h as an alias (the
  original code only had syslog.h).
2025-07-24 21:46:49 -04:00

30 lines
880 B
C

#include <syslog.h>
#include <stdlib.h>
int main(void) {
// Test that syslog succeeds without explicitly calling openlog
syslog(LOG_INFO, "Testing syslog; disregard");
closelog();
// The rest of the tests use LOG_PERROR so we get verifiable output on stderr
openlog("relibc_test",
LOG_CONS | LOG_PERROR | LOG_NDELAY,
LOG_LOCAL2
);
// Basic
syslog(LOG_EMERG, "This is a test message with extra: %d", 5);
// (This isn't available in Redox yet)
// Squelch all logs with a priority less than WARNING.
// setlogmask(LOG_UPTO(LOG_WARNING));
// First line should be emitted while the second shouldn't.
syslog(LOG_WARNING, "Foo has been bar'd");
syslog(LOG_NOTICE, "I am a very spammy log message. Ha!");
// TODO: LOG_MASK after implemented
return EXIT_SUCCESS;
}