]>
git.proxmox.com Git - mirror_frr.git/blob - bfdd/log.c
1 /*********************************************************************
2 * Copyright 2017-2018 Network Device Education Foundation, Inc. ("NetDEF")
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * log.c: implements an abstraction between loggers interface. Implement all
19 * log backends in this file.
23 * Rafael Zalamena <rzalamena@opensourcerouting.org>
30 #include "lib/log_int.h"
32 void log_msg(int level
, const char *fmt
, va_list vl
);
36 static int log_level
= BLOG_DEBUG
;
38 void log_init(int foreground
, enum blog_level level
,
39 struct frr_daemon_info
*fdi
)
44 openzlog(fdi
->progname
, fdi
->logname
, 0,
45 LOG_CONS
| LOG_NDELAY
| LOG_PID
, LOG_DAEMON
);
48 void log_msg(int level
, const char *fmt
, va_list vl
)
50 if (level
< log_level
)
55 vzlog(LOG_DEBUG
, fmt
, vl
);
59 vzlog(LOG_INFO
, fmt
, vl
);
63 vzlog(LOG_WARNING
, fmt
, vl
);
67 vzlog(LOG_ERR
, fmt
, vl
);
71 vzlog(LOG_EMERG
, fmt
, vl
);
75 vfprintf(stderr
, fmt
, vl
);
80 void log_info(const char *fmt
, ...)
85 log_msg(BLOG_INFO
, fmt
, vl
);
89 void log_debug(const char *fmt
, ...)
94 log_msg(BLOG_DEBUG
, fmt
, vl
);
98 void log_error(const char *fmt
, ...)
103 log_msg(BLOG_ERROR
, fmt
, vl
);
107 void log_warning(const char *fmt
, ...)
112 log_msg(BLOG_WARNING
, fmt
, vl
);
116 void log_fatal(const char *fmt
, ...)
121 log_msg(BLOG_FATAL
, fmt
, vl
);