blob: 96b4204ee6a9e83b7a95be51aa320c6639aab4de [file] [log] [blame]
Holger Hans Peter Freytherba01fa42011-05-12 13:46:33 +02001/* Utility functions to setup applications */
2/*
3 * (C) 2011 by Holger Hans Peter Freyther
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23#include <osmocom/core/application.h>
24#include <osmocom/core/logging.h>
25
26#include <signal.h>
27
28struct log_target *osmo_stderr_target;
29
30void osmo_init_ignore_signals(void)
31{
32 /* Signals that by default would terminate */
33 signal(SIGPIPE, SIG_IGN);
34 signal(SIGALRM, SIG_IGN);
35 signal(SIGHUP, SIG_IGN);
36 signal(SIGIO, SIG_IGN);
37}
38
39int osmo_init_logging(const struct log_info *log_info)
40{
41 log_init(log_info);
42 osmo_stderr_target = log_target_create_stderr();
43 if (!osmo_stderr_target)
44 return -1;
45
46 log_add_target(osmo_stderr_target);
47 log_set_all_filter(osmo_stderr_target, 1);
48 return 0;
49}