]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/pcep_utils_logging.h
Merge pull request #12830 from anlancs/fix/doc-ripd-rst
[mirror_frr.git] / pceplib / pcep_utils_logging.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3 * This file is part of the PCEPlib, a PCEP protocol library.
4 *
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 *
7 * Author : Brady Johnson <brady@voltanet.io>
8 *
9 */
10
11
12 #ifndef PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_
13 #define PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_
14
15 #include <syslog.h> /* Logging levels */
16 #include <stdarg.h> /* va_list */
17 #include <stdint.h> /* uint8_t */
18
19 /*
20 * The logging defined here i intended to provide the infrastructure to
21 * be able to plug-in an external logger, primarily the FRR logger. There
22 * will be a default internal logger implemented that will write to stdout,
23 * but any other advanced logging features should be implemented externally.
24 */
25
26 /* Only the following logging levels from syslog.h should be used:
27 *
28 * LOG_DEBUG - For all messages that are enabled by optional debugging
29 * features, typically preceded by "if (IS...DEBUG...)"
30 * LOG_INFO - Information that may be of interest, but
31 * everything seems to be working properly.
32 * LOG_NOTICE - Only for message pertaining to daemon startup or shutdown.
33 * LOG_WARNING - Warning conditions: unexpected events, but the daemon
34 * believes it can continue to operate correctly.
35 * LOG_ERR - Error situations indicating malfunctions.
36 * Probably requires attention.
37 */
38
39
40 /* The signature of this logger function is the same as the FRR logger */
41 typedef int (*pcep_logger_func)(int, const char *, va_list);
42 void register_logger(pcep_logger_func logger);
43
44 /* These functions only take affect when using the internal stdout logger */
45 void set_logging_level(int level);
46 int get_logging_level(void);
47
48 /* Log messages either to a previously registered
49 * logger or to the internal default stdout logger. */
50 void pcep_log(int priority, const char *format, ...);
51 void pcep_log_hexbytes(int priority, const char *message, const uint8_t *bytes,
52 uint8_t bytes_len);
53
54 #endif /* PCEP_UTILS_INCLUDE_PCEP_UTILS_LOGGING_H_ */