|
Packit Service |
f88c7f |
/*
|
|
Packit Service |
f88c7f |
* Copyright 2017 Red Hat, Inc.
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* All rights reserved.
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* Author: Jan Pokorny <jpokorny@redhat.com>
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* This file is part of libqb.
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* libqb is free software: you can redistribute it and/or modify
|
|
Packit Service |
f88c7f |
* it under the terms of the GNU Lesser General Public License as published by
|
|
Packit Service |
f88c7f |
* the Free Software Foundation, either version 2.1 of the License, or
|
|
Packit Service |
f88c7f |
* (at your option) any later version.
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* libqb is distributed in the hope that it will be useful,
|
|
Packit Service |
f88c7f |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
f88c7f |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
f88c7f |
* GNU Lesser General Public License for more details.
|
|
Packit Service |
f88c7f |
*
|
|
Packit Service |
f88c7f |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
f88c7f |
* along with libqb. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
f88c7f |
*/
|
|
Packit Service |
f88c7f |
#include "os_base.h"
|
|
Packit Service |
f88c7f |
#include <qb/qblog.h>
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
#ifndef NSELFCHECK
|
|
Packit Service |
f88c7f |
QB_LOG_INIT_DATA(linker_contra_log_lib);
|
|
Packit Service |
f88c7f |
#endif
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
void foo(void);
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
void
|
|
Packit Service |
f88c7f |
foo(void)
|
|
Packit Service |
f88c7f |
{
|
|
Packit Service |
f88c7f |
int tmpfile_fd;
|
|
Packit Service |
f88c7f |
struct stat tmpfile_stat;
|
|
Packit Service |
f88c7f |
char *tmpfile_buf = strdup("linker-log-XXXXXX");
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
#if 0
|
|
Packit Service |
f88c7f |
printf("--\n");
|
|
Packit Service |
f88c7f |
qb_log_callsites_dump();
|
|
Packit Service |
f88c7f |
printf("--\n");
|
|
Packit Service |
f88c7f |
#endif
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
#ifndef NLIBLOG
|
|
Packit Service |
f88c7f |
/* Casual test of "user-space" logging. */
|
|
Packit Service |
f88c7f |
qb_log(LOG_INFO, "aloha");
|
|
Packit Service |
f88c7f |
#endif
|
|
Packit Service |
f88c7f |
|
|
Packit Service |
f88c7f |
/* And now of "library-space" logging, i.e., let libqb generated
|
|
Packit Service |
f88c7f |
an error message on its own behalf, first to see if it will be
|
|
Packit Service |
f88c7f |
logged at all, second if it will be distinguished properly.
|
|
Packit Service |
f88c7f |
The trigger here is as simple as trying to print non-existing
|
|
Packit Service |
f88c7f |
blackbox file. */
|
|
Packit Service |
f88c7f |
tmpfile_fd = mkstemp(tmpfile_buf);
|
|
Packit Service |
f88c7f |
if (tmpfile_fd == -1) {
|
|
Packit Service |
f88c7f |
qb_perror(LOG_ERR, "creating temporary file");
|
|
Packit Service |
f88c7f |
exit(EXIT_FAILURE);
|
|
Packit Service |
f88c7f |
}
|
|
Packit Service |
f88c7f |
unlink(tmpfile_buf);
|
|
Packit Service |
f88c7f |
close(tmpfile_fd);
|
|
Packit Service |
f88c7f |
#if 0
|
|
Packit Service |
f88c7f |
if (stat(tmpfile_buf, &tmpfile_stat) == -1) {
|
|
Packit Service |
f88c7f |
qb_perror(LOG_ERR, "stat'ing nonexistent temporary file");
|
|
Packit Service |
f88c7f |
exit(EXIT_FAILURE);
|
|
Packit Service |
f88c7f |
}
|
|
Packit Service |
f88c7f |
#endif
|
|
Packit Service |
f88c7f |
qb_log_blackbox_print_from_file(tmpfile_buf);
|
|
Packit Service |
f88c7f |
free(tmpfile_buf);
|
|
Packit Service |
f88c7f |
}
|