This commit is contained in:
Imbus 2025-11-14 20:54:37 +01:00
parent 77fd1763e0
commit b5b554bf31
2 changed files with 38 additions and 0 deletions

14
syslog/Makefile Normal file
View file

@ -0,0 +1,14 @@
CC = gcc
CFLAGS = -Wall -Wextra -O2
TARGET = main.elf
SRC = main.c
#LDFLAGS =
$(TARGET): $(SRC)
@echo CC $@
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(TARGET)

24
syslog/main.c Normal file
View file

@ -0,0 +1,24 @@
#include <stdlib.h>
#include <syslog.h>
/*
* For unix systems:
* tail /var/log/messages
*
* For systems using systemd:
* journalctl -t my_daemon
*/
#define NAME "my_program"
int main(void) {
/* LOG_PID ,LOG_CONS ,LOG_ODELAY ,LOG_NDELAY ,LOG_NOWAIT ,LOG_PERROR */
openlog(NAME, LOG_PID | LOG_CONS, LOG_USER);
/* LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG */
syslog(LOG_INFO, "Hello, log!");
syslog(LOG_INFO, "Formatting works %s!", "as well");
closelog();
return EXIT_SUCCESS;
}