test-journal-send.c revision d94819c80e8262310ec6a49c406633ac122636ad
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/***
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers This file is part of systemd.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers Copyright 2011 Lennart Poettering
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers systemd is free software; you can redistribute it and/or modify it
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers under the terms of the GNU Lesser General Public License as published by
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers the Free Software Foundation; either version 2.1 of the License, or
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers (at your option) any later version.
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers systemd is distributed in the hope that it will be useful, but
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers Lesser General Public License for more details.
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers You should have received a copy of the GNU Lesser General Public License
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers***/
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers#include <errno.h>
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers#include <stdlib.h>
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers#include <unistd.h>
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers#include "sd-journal.h"
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers#include "macro.h"
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sieversint main(int argc, char *argv[]) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers char huge[4096*1024];
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_print(LOG_INFO, "piepapo");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_send("MESSAGE=foobar",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "VALUE=%i", 7,
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers NULL);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers errno = ENOENT;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_perror("Foobar");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_perror("");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers memset(huge, 'x', sizeof(huge));
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers memcpy(huge, "HUGE=", 5);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers char_array_0(huge);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_send("MESSAGE=Huge field attached",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers huge,
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers NULL);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_send("MESSAGE=uiui",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "VALUE=A",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "VALUE=B",
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers "VALUE=C",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "SINGLETON=1",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "OTHERVALUE=X",
09d8f5d757515122d7b726218e249621e564157cKay Sievers "OTHERVALUE=Y",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "WITH_BINARY=this is a binary value \a",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers NULL);
09d8f5d757515122d7b726218e249621e564157cKay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers syslog(LOG_NOTICE, "Hello World!");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_print(LOG_NOTICE, "Hello World");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sd_journal_send("MESSAGE=Hello World!",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "MESSAGE_ID=52fb62f99e2c49d89cfbf9d6de5e3555",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "PRIORITY=5",
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "HOME=%s", getenv("HOME"),
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "TERM=%s", getenv("TERM"),
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "PAGE_SIZE=%li", sysconf(_SC_PAGESIZE),
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "N_CPUS=%li", sysconf(_SC_NPROCESSORS_ONLN),
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers NULL);
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers sleep(1);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
09d8f5d757515122d7b726218e249621e564157cKay Sievers return 0;
09d8f5d757515122d7b726218e249621e564157cKay Sievers}
09d8f5d757515122d7b726218e249621e564157cKay Sievers