]> git.proxmox.com Git - mirror_frr.git/blame - pceplib/pcep_utils_logging.h
Merge pull request #10775 from opensourcerouting/pim6-mld-pr
[mirror_frr.git] / pceplib / pcep_utils_logging.h
CommitLineData
74971473
JG
1/*
2 * This file is part of the PCEPlib, a PCEP protocol library.
3 *
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Author : Brady Johnson <brady@voltanet.io>
20 *
21 */
22
23
24#ifndef PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_
25#define PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_
26
27#include <syslog.h> /* Logging levels */
28#include <stdarg.h> /* va_list */
29#include <stdint.h> /* uint8_t */
30
31/*
32 * The logging defined here i intended to provide the infrastructure to
33 * be able to plug-in an external logger, primarily the FRR logger. There
34 * will be a default internal logger implemented that will write to stdout,
35 * but any other advanced logging features should be implemented externally.
36 */
37
38/* Only the following logging levels from syslog.h should be used:
39 *
40 * LOG_DEBUG - For all messages that are enabled by optional debugging
41 * features, typically preceded by "if (IS...DEBUG...)"
42 * LOG_INFO - Information that may be of interest, but
43 * everything seems to be working properly.
44 * LOG_NOTICE - Only for message pertaining to daemon startup or shutdown.
45 * LOG_WARNING - Warning conditions: unexpected events, but the daemon
46 * believes it can continue to operate correctly.
47 * LOG_ERR - Error situations indicating malfunctions.
48 * Probably requires attention.
49 */
50
51
52/* The signature of this logger function is the same as the FRR logger */
53typedef int (*pcep_logger_func)(int, const char *, va_list);
54void register_logger(pcep_logger_func logger);
55
56/* These functions only take affect when using the internal stdout logger */
57void set_logging_level(int level);
58int get_logging_level(void);
59
60/* Log messages either to a previously registered
61 * logger or to the internal default stdout logger. */
62void pcep_log(int priority, const char *format, ...);
63void pcep_log_hexbytes(int priority, const char *message, const uint8_t *bytes,
64 uint8_t bytes_len);
65
66#endif /* PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_ */