test-journal-send.c revision 1dfa7e79a60de680086b1d93fcc3629b463f58bd
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering/***
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering This file is part of systemd.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering Copyright 2011 Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering systemd is free software; you can redistribute it and/or modify it
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering under the terms of the GNU Lesser General Public License as published by
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering (at your option) any later version.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering systemd is distributed in the hope that it will be useful, but
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering Lesser General Public License for more details.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering You should have received a copy of the GNU Lesser General Public License
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering***/
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include <systemd/sd-journal.h>
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "log.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint main(int argc, char *argv[]) {
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering char huge[4096*1024];
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering log_set_max_level(LOG_DEBUG);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering sd_journal_print(LOG_INFO, "piepapo");
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering sd_journal_send("MESSAGE=foobar",
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering "VALUE=%i", 7,
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering NULL);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering errno = ENOENT;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering sd_journal_perror("Foobar");
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering sd_journal_perror("");
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering memset(huge, 'x', sizeof(huge));
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering memcpy(huge, "HUGE=", 5);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering char_array_0(huge);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering sd_journal_send("MESSAGE=Huge field attached",
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering huge,
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering NULL);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering return 0;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering}
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering